| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
package net.sf.saxon.tree.tiny; |
| 9 |
|
| 10 |
import com.saxonica.ee.validate.SkipValidator; |
| 11 |
import net.sf.saxon.Configuration; |
| 12 |
import net.sf.saxon.event.*; |
| 13 |
import net.sf.saxon.expr.parser.ExplicitLocation; |
| 14 |
import net.sf.saxon.expr.parser.Location; |
| 15 |
import net.sf.saxon.om.*; |
| 16 |
import net.sf.saxon.trans.XPathException; |
| 17 |
import net.sf.saxon.tree.util.NamespaceIterator; |
| 18 |
import net.sf.saxon.tree.util.Navigator; |
| 19 |
import net.sf.saxon.type.*; |
| 20 |
import net.sf.saxon.value.AtomicValue; |
| 21 |
import net.sf.saxon.z.IntHashMap; |
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
public class TinyElementImpl extends TinyParentNodeImpl { |
| 34 |
|
| 35 |
|
| 36 |
|
| 37 |
|
| 38 |
|
| 39 |
|
| 40 |
|
| 41 |
|
| 42 |
public TinyElementImpl(TinyTree tree, int nodeNr) { |
| 43 |
this.tree = tree; |
| 44 |
this.nodeNr = nodeNr; |
| 45 |
} |
| 46 |
|
| 47 |
|
| 48 |
|
| 49 |
|
| 50 |
|
| 51 |
|
| 52 |
|
| 53 |
public final int getNodeKind() { |
| 54 |
return Type.ELEMENT; |
| 55 |
} |
| 56 |
|
| 57 |
|
| 58 |
|
| 59 |
|
| 60 |
|
| 61 |
|
| 62 |
public String getBaseURI() { |
| 63 |
synchronized (tree) { |
| 64 |
if (tree.knownBaseUris == null) { |
| 65 |
tree.knownBaseUris = new IntHashMap<>(); |
| 66 |
} |
| 67 |
String uri = tree.knownBaseUris.get(nodeNr); |
| 68 |
if (uri == null) { |
| 69 |
uri = Navigator.getBaseURI(this, |
| 70 |
n -> tree.isTopWithinEntity(((TinyElementImpl) n).getNodeNumber())); |
| 71 |
tree.knownBaseUris.put(nodeNr, uri); |
| 72 |
} |
| 73 |
return uri; |
| 74 |
} |
| 75 |
} |
| 76 |
|
| 77 |
|
| 78 |
|
| 79 |
|
| 80 |
|
| 81 |
|
| 82 |
|
| 83 |
|
| 84 |
|
| 85 |
|
| 86 |
|
| 87 |
|
| 88 |
|
| 89 |
@Override |
| 90 |
public SchemaType getSchemaType() { |
| 91 |
return tree.getSchemaType(nodeNr); |
| 92 |
} |
| 93 |
|
| 94 |
|
| 95 |
|
| 96 |
|
| 97 |
|
| 98 |
|
| 99 |
|
| 100 |
|
| 101 |
public AtomicSequence atomize() throws XPathException { |
| 102 |
return tree.getTypedValueOfElement(this); |
| 103 |
} |
| 104 |
|
| 105 |
|
| 106 |
|
| 107 |
|
| 108 |
|
| 109 |
|
| 110 |
|
| 111 |
|
| 112 |
|
| 113 |
|
| 114 |
|
| 115 |
|
| 116 |
|
| 117 |
|
| 118 |
|
| 119 |
public NamespaceBinding[] getDeclaredNamespaces(NamespaceBinding[] buffer) { |
| 120 |
return getDeclaredNamespaces(tree, nodeNr, buffer); |
| 121 |
} |
| 122 |
|
| 123 |
|
| 124 |
|
| 125 |
|
| 126 |
|
| 127 |
|
| 128 |
|
| 129 |
|
| 130 |
|
| 131 |
|
| 132 |
|
| 133 |
|
| 134 |
|
| 135 |
|
| 136 |
|
| 137 |
|
| 138 |
|
| 139 |
|
| 140 |
public static NamespaceBinding[] getDeclaredNamespaces( TinyTree tree, int nodeNr, NamespaceBinding[] buffer) { |
| 141 |
int ns = tree.beta[nodeNr]; |
| 142 |
if (ns > 0) { |
| 143 |
int count = 0; |
| 144 |
while (ns < tree.numberOfNamespaces && |
| 145 |
tree.namespaceParent[ns] == nodeNr) { |
| 146 |
count++; |
| 147 |
ns++; |
| 148 |
} |
| 149 |
if (count == 0) { |
| 150 |
return NamespaceBinding.EMPTY_ARRAY; |
| 151 |
} else if (buffer != null && count <= buffer.length) { |
| 152 |
System.arraycopy(tree.namespaceBinding, tree.beta[nodeNr], buffer, 0, count); |
| 153 |
if (count < buffer.length) { |
| 154 |
buffer[count] = null; |
| 155 |
} |
| 156 |
return buffer; |
| 157 |
} else { |
| 158 |
NamespaceBinding[] array = new NamespaceBinding[count]; |
| 159 |
System.arraycopy(tree.namespaceBinding, tree.beta[nodeNr], array, 0, count); |
| 160 |
return array; |
| 161 |
} |
| 162 |
} else { |
| 163 |
return NamespaceBinding.EMPTY_ARRAY; |
| 164 |
} |
| 165 |
} |
| 166 |
|
| 167 |
|
| 168 |
|
| 169 |
|
| 170 |
|
| 171 |
|
| 172 |
|
| 173 |
|
| 174 |
|
| 175 |
public boolean hasUniformNamespaces() { |
| 176 |
int nr = nodeNr; |
| 177 |
int ns = tree.beta[nr]; |
| 178 |
TinyElementImpl anc = this; |
| 179 |
while (ns == -1) { |
| 180 |
TinyNodeImpl parent = anc.getParent(); |
| 181 |
if (parent instanceof TinyDocumentImpl) { |
| 182 |
return !tree.usesNamespaces; |
| 183 |
} else { |
| 184 |
nr = parent.nodeNr; |
| 185 |
ns = tree.beta[nr]; |
| 186 |
anc = (TinyElementImpl)parent; |
| 187 |
} |
| 188 |
} |
| 189 |
|
| 190 |
while (ns < tree.numberOfNamespaces && tree.namespaceParent[ns] == nr) { |
| 191 |
ns++; |
| 192 |
} |
| 193 |
|
| 194 |
|
| 195 |
return ns >= tree.numberOfNamespaces || !isAncestorOrSelf(tree.getNode(tree.namespaceParent[ns])); |
| 196 |
} |
| 197 |
|
| 198 |
|
| 199 |
|
| 200 |
|
| 201 |
|
| 202 |
|
| 203 |
|
| 204 |
|
| 205 |
|
| 206 |
|
| 207 |
|
| 208 |
|
| 209 |
|
| 210 |
@Override |
| 211 |
public String getAttributeValue( String uri, String local) { |
| 212 |
int a = tree.alpha[nodeNr]; |
| 213 |
if (a < 0) { |
| 214 |
return null; |
| 215 |
} |
| 216 |
NamePool pool = getNamePool(); |
| 217 |
while (a < tree.numberOfAttributes && tree.attParent[a] == nodeNr) { |
| 218 |
int nc = tree.attCode[a]; |
| 219 |
|
| 220 |
StructuredQName name = pool.getUnprefixedQName(nc); |
| 221 |
if (name.getLocalPart().equals(local) && name.hasURI(uri)) { |
| 222 |
return tree.attValue[a].toString(); |
| 223 |
} |
| 224 |
a++; |
| 225 |
} |
| 226 |
return null; |
| 227 |
} |
| 228 |
|
| 229 |
|
| 230 |
|
| 231 |
|
| 232 |
|
| 233 |
|
| 234 |
|
| 235 |
|
| 236 |
public String getAttributeValue(int fp) { |
| 237 |
|
| 238 |
int a = tree.alpha[nodeNr]; |
| 239 |
if (a < 0) { |
| 240 |
return null; |
| 241 |
} |
| 242 |
while (a < tree.numberOfAttributes && tree.attParent[a] == nodeNr) { |
| 243 |
if (fp == (tree.attCode[a] & NamePool.FP_MASK)) { |
| 244 |
return tree.attValue[a].toString(); |
| 245 |
} |
| 246 |
a++; |
| 247 |
} |
| 248 |
return null; |
| 249 |
} |
| 250 |
|
| 251 |
private int subtreeSize() { |
| 252 |
int next = tree.next[nodeNr]; |
| 253 |
while (next < nodeNr) { |
| 254 |
if (next < 0) { |
| 255 |
return tree.numberOfNodes - nodeNr; |
| 256 |
} |
| 257 |
next = tree.next[next]; |
| 258 |
} |
| 259 |
return nodeNr - next; |
| 260 |
} |
| 261 |
|
| 262 |
|
| 263 |
|
| 264 |
|
| 265 |
|
| 266 |
|
| 267 |
|
| 268 |
|
| 269 |
public void copy( Receiver receiver, int copyOptions, Location location) throws XPathException { |
| 270 |
|
| 271 |
boolean copyTypes = CopyOptions.includes(copyOptions, CopyOptions.TYPE_ANNOTATIONS); |
| 272 |
|
| 273 |
boolean fastCopied = tryBulkCopy(copyOptions, receiver); |
| 274 |
if (fastCopied) { |
| 275 |
return; |
| 276 |
} |
| 277 |
|
| 278 |
|
| 279 |
|
| 280 |
|
| 281 |
|
| 282 |
|
| 283 |
|
| 284 |
|
| 285 |
|
| 286 |
|
| 287 |
short level = -1; |
| 288 |
boolean closePending = false; |
| 289 |
short startLevel = tree.depth[nodeNr]; |
| 290 |
boolean first = true; |
| 291 |
boolean disallowNamespaceSensitiveContent = |
| 292 |
((copyOptions & CopyOptions.TYPE_ANNOTATIONS) != 0) && |
| 293 |
((copyOptions & CopyOptions.SOME_NAMESPACES) == 0); |
| 294 |
boolean foundElementInDefaultNamespace = false; |
| 295 |
Configuration config = tree.getConfiguration(); |
| 296 |
NamePool pool = config.getNamePool(); |
| 297 |
int next = nodeNr; |
| 298 |
CopyInformee<Location> informee = (CopyInformee<Location>) receiver.getPipelineConfiguration().getComponent(CopyInformee.class.getName()); |
| 299 |
SchemaType elementType = Untyped.getInstance(); |
| 300 |
SimpleType attributeType = BuiltInAtomicType.UNTYPED_ATOMIC; |
| 301 |
|
| 302 |
|
| 303 |
do { |
| 304 |
|
| 305 |
|
| 306 |
short nodeLevel = tree.depth[next]; |
| 307 |
|
| 308 |
|
| 309 |
if (closePending) { |
| 310 |
level++; |
| 311 |
} |
| 312 |
|
| 313 |
|
| 314 |
for (; level > nodeLevel; level--) { |
| 315 |
receiver.endElement(); |
| 316 |
} |
| 317 |
|
| 318 |
|
| 319 |
level = nodeLevel; |
| 320 |
|
| 321 |
|
| 322 |
int kind = tree.nodeKind[next]; |
| 323 |
switch (kind) { |
| 324 |
case Type.ELEMENT: |
| 325 |
case Type.TEXTUAL_ELEMENT: { |
| 326 |
|
| 327 |
|
| 328 |
if (copyTypes) { |
| 329 |
elementType = tree.getSchemaType(next); |
| 330 |
if (disallowNamespaceSensitiveContent) { |
| 331 |
try { |
| 332 |
checkNotNamespaceSensitiveElement(elementType, next); |
| 333 |
} catch (CopyNamespaceSensitiveException e) { |
| 334 |
int lang = receiver.getPipelineConfiguration().getHostLanguage(); |
| 335 |
e.setErrorCode(lang == Configuration.XSLT ? "XTTE0950" : "XQTY0086"); |
| 336 |
throw e; |
| 337 |
} |
| 338 |
} |
| 339 |
} |
| 340 |
if (informee != null) { |
| 341 |
Location loc = informee.notifyElementNode(tree.getNode(next)); |
| 342 |
if (loc != null) { |
| 343 |
location = loc; |
| 344 |
} |
| 345 |
} |
| 346 |
int nameCode = tree.nameCode[next]; |
| 347 |
int fp = nameCode & NamePool.FP_MASK; |
| 348 |
String prefix = tree.getPrefix(next); |
| 349 |
int options = !first && (copyOptions & CopyOptions.SOME_NAMESPACES) != 0 |
| 350 |
? ReceiverOptions.NAMESPACE_OK |
| 351 |
: 0; |
| 352 |
|
| 353 |
if (location.getLineNumber() < tree.getLineNumber(next)) { |
| 354 |
String systemId = location.getSystemId() == null ? getSystemId() : location.getSystemId(); |
| 355 |
location = new ExplicitLocation(systemId, tree.getLineNumber(next), getColumnNumber()); |
| 356 |
} |
| 357 |
|
| 358 |
receiver.startElement(new CodedName(fp, prefix, pool), |
| 359 |
elementType, location, options); |
| 360 |
|
| 361 |
if (kind == Type.TEXTUAL_ELEMENT) { |
| 362 |
closePending = false; |
| 363 |
receiver.startContent(); |
| 364 |
|
| 365 |
final CharSequence value = TinyTextImpl.getStringValue(tree, next); |
| 366 |
receiver.characters(value, location, ReceiverOptions.WHOLE_TEXT_NODE); |
| 367 |
receiver.endElement(); |
| 368 |
} else { |
| 369 |
|
| 370 |
closePending = true; |
| 371 |
|
| 372 |
|
| 373 |
if ((copyOptions & CopyOptions.SOME_NAMESPACES) != 0 && tree.usesNamespaces) { |
| 374 |
String defaultNS = null; |
| 375 |
if (prefix.isEmpty()) { |
| 376 |
defaultNS = getNamePool().getURI(fp); |
| 377 |
if (!defaultNS.isEmpty()) { |
| 378 |
foundElementInDefaultNamespace = true; |
| 379 |
} |
| 380 |
} |
| 381 |
if (first) { |
| 382 |
if ((copyOptions & CopyOptions.LOCAL_NAMESPACES) != 0) { |
| 383 |
NamespaceBinding[] localNamespaces = getDeclaredNamespaces(null); |
| 384 |
for (NamespaceBinding ns : localNamespaces) { |
| 385 |
if (ns == null) { |
| 386 |
break; |
| 387 |
} |
| 388 |
receiver.namespace(ns, 0); |
| 389 |
} |
| 390 |
} else if ((copyOptions & CopyOptions.ALL_NAMESPACES) != 0) { |
| 391 |
NamespaceIterator.sendNamespaces(this, receiver); |
| 392 |
} |
| 393 |
} else { |
| 394 |
int ns = tree.beta[next]; |
| 395 |
if (ns > 0) { |
| 396 |
while (ns < tree.numberOfNamespaces && |
| 397 |
tree.namespaceParent[ns] == next) { |
| 398 |
NamespaceBinding nscode = tree.namespaceBinding[ns]; |
| 399 |
receiver.namespace(nscode, 0); |
| 400 |
ns++; |
| 401 |
} |
| 402 |
} |
| 403 |
} |
| 404 |
} |
| 405 |
first = false; |
| 406 |
|
| 407 |
|
| 408 |
|
| 409 |
int att = tree.alpha[next]; |
| 410 |
if (att >= 0) { |
| 411 |
while (att < tree.numberOfAttributes && tree.attParent[att] == next) { |
| 412 |
int attCode = tree.attCode[att]; |
| 413 |
int attfp = attCode & NamePool.FP_MASK; |
| 414 |
if (copyTypes) { |
| 415 |
attributeType = tree.getAttributeType(att); |
| 416 |
if (disallowNamespaceSensitiveContent) { |
| 417 |
try { |
| 418 |
checkNotNamespaceSensitiveAttribute(attributeType, att); |
| 419 |
} catch (CopyNamespaceSensitiveException e) { |
| 420 |
int lang = receiver.getPipelineConfiguration().getHostLanguage(); |
| 421 |
e.setErrorCode(lang == Configuration.XSLT ? "XTTE0950" : "XQTY0086"); |
| 422 |
throw e; |
| 423 |
} |
| 424 |
} |
| 425 |
} |
| 426 |
String attPrefix = tree.prefixPool.getPrefix(attCode >> 20); |
| 427 |
receiver.attribute(new CodedName(attfp, attPrefix, pool), attributeType, tree.attValue[att], location, ReceiverOptions.NOT_A_DUPLICATE); |
| 428 |
att++; |
| 429 |
} |
| 430 |
} |
| 431 |
|
| 432 |
|
| 433 |
receiver.startContent(); |
| 434 |
} |
| 435 |
break; |
| 436 |
} |
| 437 |
|
| 438 |
case Type.EXTERNAL_NODE_REFERENCE: |
| 439 |
closePending = false; |
| 440 |
tree.externalNodes.get(tree.alpha[next]).copy(receiver, copyOptions, location); |
| 441 |
break; |
| 442 |
|
| 443 |
case Type.TEXT: { |
| 444 |
|
| 445 |
|
| 446 |
closePending = false; |
| 447 |
|
| 448 |
|
| 449 |
final CharSequence value = TinyTextImpl.getStringValue(tree, next); |
| 450 |
receiver.characters(value, location, ReceiverOptions.WHOLE_TEXT_NODE); |
| 451 |
break; |
| 452 |
} |
| 453 |
|
| 454 |
case Type.WHITESPACE_TEXT: { |
| 455 |
|
| 456 |
|
| 457 |
closePending = false; |
| 458 |
|
| 459 |
|
| 460 |
final CharSequence value = WhitespaceTextImpl.getStringValueCS(tree, next); |
| 461 |
receiver.characters(value, location, ReceiverOptions.WHOLE_TEXT_NODE); |
| 462 |
break; |
| 463 |
} |
| 464 |
|
| 465 |
case Type.COMMENT: { |
| 466 |
|
| 467 |
|
| 468 |
closePending = false; |
| 469 |
|
| 470 |
|
| 471 |
int start = tree.alpha[next]; |
| 472 |
int len = tree.beta[next]; |
| 473 |
if (len > 0) { |
| 474 |
receiver.comment(tree.commentBuffer.subSequence(start, start + len), location, 0); |
| 475 |
} else { |
| 476 |
receiver.comment("", ExplicitLocation.UNKNOWN_LOCATION, 0); |
| 477 |
} |
| 478 |
break; |
| 479 |
} |
| 480 |
case Type.PROCESSING_INSTRUCTION: { |
| 481 |
|
| 482 |
|
| 483 |
closePending = false; |
| 484 |
|
| 485 |
|
| 486 |
NodeInfo pi = tree.getNode(next); |
| 487 |
receiver.processingInstruction(pi.getLocalPart(), pi.getStringValue(), location, 0); |
| 488 |
break; |
| 489 |
} |
| 490 |
|
| 491 |
case Type.PARENT_POINTER: { |
| 492 |
closePending = false; |
| 493 |
} |
| 494 |
} |
| 495 |
|
| 496 |
next++; |
| 497 |
|
| 498 |
} while (next < tree.numberOfNodes && tree.depth[next] > startLevel); |
| 499 |
|
| 500 |
|
| 501 |
if (closePending) { |
| 502 |
level++; |
| 503 |
} |
| 504 |
for (; level > startLevel; level--) { |
| 505 |
receiver.endElement(); |
| 506 |
} |
| 507 |
} |
| 508 |
|
| 509 |
private boolean tryGraft(int copyOptions, Receiver out) throws XPathException { |
| 510 |
if (subtreeSize() < 100) { |
| 511 |
return false; |
| 512 |
} |
| 513 |
if (TinyTree.useGraft && |
| 514 |
(copyOptions & CopyOptions.FOR_UPDATE) == 0 && |
| 515 |
(copyOptions & CopyOptions.ALL_NAMESPACES) != 0 && |
| 516 |
|
| 517 |
tree.externalNodes == null) { |
| 518 |
if (isSkipValidator(out)) { |
| 519 |
return false; |
| 520 |
|
| 521 |
|
| 522 |
|
| 523 |
} |
| 524 |
if (tree.isTyped()) { |
| 525 |
return false; |
| 526 |
} |
| 527 |
if (out instanceof SequenceWriter && ((SequenceWriter) out).isReadyForGrafting()) { |
| 528 |
((SequenceWriter) out).graftElementNode(this, copyOptions); |
| 529 |
return true; |
| 530 |
} else if (out instanceof ComplexContentOutputter) { |
| 531 |
if (((ComplexContentOutputter) out).isReadyForGrafting()) { |
| 532 |
((ComplexContentOutputter) out).graftElementNode(this, copyOptions); |
| 533 |
return true; |
| 534 |
} |
| 535 |
} |
| 536 |
} |
| 537 |
return false; |
| 538 |
} |
| 539 |
|
| 540 |
private boolean tryBulkCopy(int copyOptions, Receiver out) throws XPathException { |
| 541 |
|
| 542 |
if (TinyTree.useBulkCopy && |
| 543 |
(copyOptions & CopyOptions.FOR_UPDATE) == 0 && |
| 544 |
(copyOptions & CopyOptions.ALL_NAMESPACES) != 0 && |
| 545 |
|
| 546 |
tree.externalNodes == null) { |
| 547 |
if (isSkipValidator(out)) { |
| 548 |
out = ((ProxyReceiver)out).getNextReceiver(); |
| 549 |
} |
| 550 |
if (tree.isTyped()) { |
| 551 |
return false; |
| 552 |
} |
| 553 |
if (nodeNr == tree.numberOfNodes - 1) { |
| 554 |
|
| 555 |
|
| 556 |
return false; |
| 557 |
} |
| 558 |
if (out instanceof SequenceWriter && ((SequenceWriter) out).isReadyForBulkCopy()) { |
| 559 |
((SequenceWriter) out).bulkCopyElementNode(this, copyOptions); |
| 560 |
return true; |
| 561 |
} else if (out instanceof ComplexContentOutputter) { |
| 562 |
if (((ComplexContentOutputter) out).isReadyForBulkCopy()) { |
| 563 |
((ComplexContentOutputter) out).bulkCopyElementNode(this, copyOptions); |
| 564 |
return true; |
| 565 |
} |
| 566 |
} |
| 567 |
} |
| 568 |
return false; |
| 569 |
} |
| 570 |
|
| 571 |
|
| 572 |
|
| 573 |
|
| 574 |
|
| 575 |
|
| 576 |
|
| 577 |
|
| 578 |
|
| 579 |
|
| 580 |
protected void checkNotNamespaceSensitiveElement(SchemaType type, int nodeNr) throws XPathException { |
| 581 |
if (type instanceof SimpleType && ((SimpleType) type).isNamespaceSensitive()) { |
| 582 |
if (type.isAtomicType()) { |
| 583 |
throw new CopyNamespaceSensitiveException( |
| 584 |
"Cannot copy QName or NOTATION values without copying namespaces"); |
| 585 |
} else { |
| 586 |
|
| 587 |
AtomicSequence value = tree.getTypedValueOfElement(nodeNr); |
| 588 |
for (AtomicValue val : value) { |
| 589 |
if (val.getPrimitiveType().isNamespaceSensitive()) { |
| 590 |
throw new CopyNamespaceSensitiveException( |
| 591 |
"Cannot copy QName or NOTATION values without copying namespaces"); |
| 592 |
} |
| 593 |
} |
| 594 |
} |
| 595 |
} |
| 596 |
} |
| 597 |
|
| 598 |
|
| 599 |
|
| 600 |
|
| 601 |
|
| 602 |
|
| 603 |
|
| 604 |
|
| 605 |
|
| 606 |
|
| 607 |
private void checkNotNamespaceSensitiveAttribute(SimpleType type, int nodeNr) throws XPathException { |
| 608 |
if (type.isNamespaceSensitive()) { |
| 609 |
if (type.isAtomicType()) { |
| 610 |
throw new CopyNamespaceSensitiveException( |
| 611 |
"Cannot copy QName or NOTATION values without copying namespaces"); |
| 612 |
} else { |
| 613 |
|
| 614 |
AtomicSequence value = tree.getTypedValueOfAttribute(null, nodeNr); |
| 615 |
for (AtomicValue val : value) { |
| 616 |
if (val.getPrimitiveType().isNamespaceSensitive()) { |
| 617 |
throw new CopyNamespaceSensitiveException( |
| 618 |
"Cannot copy QName or NOTATION values without copying namespaces"); |
| 619 |
} |
| 620 |
} |
| 621 |
} |
| 622 |
} |
| 623 |
} |
| 624 |
|
| 625 |
|
| 626 |
|
| 627 |
|
| 628 |
|
| 629 |
|
| 630 |
|
| 631 |
|
| 632 |
|
| 633 |
|
| 634 |
|
| 635 |
|
| 636 |
|
| 637 |
|
| 638 |
|
| 639 |
|
| 640 |
public String getURIForPrefix( String prefix, boolean useDefault) { |
| 641 |
if (!useDefault && (prefix == null || prefix.isEmpty())) { |
| 642 |
return ""; |
| 643 |
} |
| 644 |
int ns = tree.beta[nodeNr]; |
| 645 |
if (ns > 0) { |
| 646 |
while (ns < tree.numberOfNamespaces && |
| 647 |
tree.namespaceParent[ns] == nodeNr) { |
| 648 |
NamespaceBinding nscode = tree.namespaceBinding[ns]; |
| 649 |
if (nscode.getPrefix().equals(prefix)) { |
| 650 |
String uri = nscode.getURI(); |
| 651 |
if (uri.isEmpty()) { |
| 652 |
|
| 653 |
if (prefix.isEmpty()) { |
| 654 |
|
| 655 |
return ""; |
| 656 |
} else { |
| 657 |
return null; |
| 658 |
} |
| 659 |
} else { |
| 660 |
return uri; |
| 661 |
} |
| 662 |
} |
| 663 |
ns++; |
| 664 |
} |
| 665 |
} |
| 666 |
|
| 667 |
|
| 668 |
|
| 669 |
NodeInfo parent = getParent(); |
| 670 |
if (parent instanceof NamespaceResolver) { |
| 671 |
return ((NamespaceResolver) parent).getURIForPrefix(prefix, useDefault); |
| 672 |
} |
| 673 |
return null; |
| 674 |
} |
| 675 |
|
| 676 |
|
| 677 |
|
| 678 |
|
| 679 |
|
| 680 |
|
| 681 |
|
| 682 |
public boolean isId() { |
| 683 |
|
| 684 |
return tree.isIdElement(nodeNr); |
| 685 |
} |
| 686 |
|
| 687 |
|
| 688 |
|
| 689 |
|
| 690 |
|
| 691 |
|
| 692 |
|
| 693 |
public boolean isIdref() { |
| 694 |
return tree.isIdrefElement(nodeNr); |
| 695 |
} |
| 696 |
|
| 697 |
private boolean isSkipValidator(Receiver r) { |
| 698 |
|
| 699 |
if (r instanceof SkipValidator) { |
| 700 |
return true; |
| 701 |
} |
| 702 |
|
| 703 |
return false; |
| 704 |
} |
| 705 |
|
| 706 |
|
| 707 |
} |
| 708 |
|