| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
package net.sf.saxon.event; |
| 9 |
|
| 10 |
import net.sf.saxon.Configuration; |
| 11 |
import net.sf.saxon.expr.parser.ExplicitLocation; |
| 12 |
import net.sf.saxon.expr.parser.Location; |
| 13 |
import net.sf.saxon.lib.NamespaceConstant; |
| 14 |
import net.sf.saxon.lib.ParseOptions; |
| 15 |
import net.sf.saxon.lib.Validation; |
| 16 |
import net.sf.saxon.om.*; |
| 17 |
import net.sf.saxon.trans.Err; |
| 18 |
import net.sf.saxon.trans.XPathException; |
| 19 |
import net.sf.saxon.tree.tiny.TinyBuilder; |
| 20 |
import net.sf.saxon.tree.tiny.TinyElementImpl; |
| 21 |
import net.sf.saxon.type.BuiltInAtomicType; |
| 22 |
import net.sf.saxon.type.SchemaType; |
| 23 |
import net.sf.saxon.type.SimpleType; |
| 24 |
import net.sf.saxon.type.Type; |
| 25 |
|
| 26 |
import java.util.Arrays; |
| 27 |
|
| 28 |
import static net.sf.saxon.event.RegularSequenceChecker.State.*; |
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
|
| 35 |
|
| 36 |
|
| 37 |
|
| 38 |
|
| 39 |
|
| 40 |
|
| 41 |
|
| 42 |
|
| 43 |
|
| 44 |
|
| 45 |
|
| 46 |
|
| 47 |
|
| 48 |
|
| 49 |
|
| 50 |
|
| 51 |
public final class ComplexContentOutputter extends SequenceReceiver { |
| 52 |
|
| 53 |
private Receiver nextReceiver; |
| 54 |
|
| 55 |
|
| 56 |
private NodeName pendingStartTag = null; |
| 57 |
private int level = -1; |
| 58 |
|
| 59 |
|
| 60 |
|
| 61 |
|
| 62 |
|
| 63 |
private boolean[] currentLevelIsDocument = new boolean[20]; |
| 64 |
private InScopeNamespaces[] copyNamespacesStack = new InScopeNamespaces[20]; |
| 65 |
private Boolean elementIsInNullNamespace; |
| 66 |
private NodeName[] pendingAttCode = new NodeName[20]; |
| 67 |
private SimpleType[] pendingAttType = new SimpleType[20]; |
| 68 |
private String[] pendingAttValue = new String[20]; |
| 69 |
private Location[] pendingAttLocation = new Location[20]; |
| 70 |
private int[] pendingAttProp = new int[20]; |
| 71 |
private int pendingAttListSize = 0; |
| 72 |
|
| 73 |
private NamespaceBinding[] pendingNSList = new NamespaceBinding[20]; |
| 74 |
private int pendingNSListSize = 0; |
| 75 |
|
| 76 |
private SchemaType currentSimpleType = null; |
| 77 |
|
| 78 |
|
| 79 |
private int startElementProperties; |
| 80 |
private Location startElementLocationId = ExplicitLocation.UNKNOWN_LOCATION; |
| 81 |
private boolean declaresDefaultNamespace; |
| 82 |
private int hostLanguage = Configuration.XSLT; |
| 83 |
|
| 84 |
private RegularSequenceChecker.State state = Initial; |
| 85 |
|
| 86 |
|
| 87 |
|
| 88 |
|
| 89 |
|
| 90 |
public ComplexContentOutputter(Receiver next) { |
| 91 |
super(next.getPipelineConfiguration()); |
| 92 |
setReceiver(next); |
| 93 |
setHostLanguage(next.getPipelineConfiguration().getHostLanguage()); |
| 94 |
} |
| 95 |
|
| 96 |
|
| 97 |
|
| 98 |
|
| 99 |
|
| 100 |
|
| 101 |
|
| 102 |
public static Receiver makeComplexContentReceiver(Receiver receiver, ParseOptions options) { |
| 103 |
|
| 104 |
|
| 105 |
String systemId = receiver.getSystemId(); |
| 106 |
boolean validate = options != null && options.getSchemaValidationMode() != Validation.PRESERVE; |
| 107 |
|
| 108 |
if (receiver instanceof ComplexContentOutputter && !validate) { |
| 109 |
return receiver; |
| 110 |
} |
| 111 |
|
| 112 |
|
| 113 |
|
| 114 |
if (validate) { |
| 115 |
Configuration config = receiver.getPipelineConfiguration().getConfiguration(); |
| 116 |
receiver = config.getDocumentValidator(receiver, systemId, options, null); |
| 117 |
} |
| 118 |
|
| 119 |
|
| 120 |
NamespaceReducer ne = new NamespaceReducer(receiver); |
| 121 |
ne.setSystemId(receiver.getSystemId()); |
| 122 |
receiver = ne; |
| 123 |
|
| 124 |
receiver = new ComplexContentOutputter(ne); |
| 125 |
|
| 126 |
receiver.setSystemId(systemId); |
| 127 |
return receiver; |
| 128 |
} |
| 129 |
|
| 130 |
public void setPipelineConfiguration( PipelineConfiguration pipe) { |
| 131 |
if (pipelineConfiguration != pipe) { |
| 132 |
pipelineConfiguration = pipe; |
| 133 |
if (nextReceiver != null) { |
| 134 |
nextReceiver.setPipelineConfiguration(pipe); |
| 135 |
} |
| 136 |
} |
| 137 |
} |
| 138 |
|
| 139 |
@Override |
| 140 |
public void setSystemId(String systemId) { |
| 141 |
super.setSystemId(systemId); |
| 142 |
nextReceiver.setSystemId(systemId); |
| 143 |
} |
| 144 |
|
| 145 |
|
| 146 |
|
| 147 |
|
| 148 |
|
| 149 |
|
| 150 |
|
| 151 |
public void setHostLanguage(int language) { |
| 152 |
hostLanguage = language; |
| 153 |
} |
| 154 |
|
| 155 |
|
| 156 |
|
| 157 |
|
| 158 |
|
| 159 |
|
| 160 |
|
| 161 |
|
| 162 |
public void setReceiver(Receiver receiver) { |
| 163 |
this.nextReceiver = receiver; |
| 164 |
} |
| 165 |
|
| 166 |
|
| 167 |
|
| 168 |
|
| 169 |
|
| 170 |
|
| 171 |
|
| 172 |
public Receiver getReceiver() { |
| 173 |
return nextReceiver; |
| 174 |
} |
| 175 |
|
| 176 |
|
| 177 |
|
| 178 |
|
| 179 |
|
| 180 |
|
| 181 |
public void open() throws XPathException { |
| 182 |
nextReceiver.open(); |
| 183 |
previousAtomic = false; |
| 184 |
state = Open; |
| 185 |
} |
| 186 |
|
| 187 |
|
| 188 |
|
| 189 |
|
| 190 |
|
| 191 |
public void startDocument(int properties) throws XPathException { |
| 192 |
level++; |
| 193 |
if (level == 0) { |
| 194 |
nextReceiver.startDocument(properties); |
| 195 |
} else if (state == StartTag) { |
| 196 |
startContent(); |
| 197 |
} |
| 198 |
previousAtomic = false; |
| 199 |
if (currentLevelIsDocument.length < level + 1) { |
| 200 |
currentLevelIsDocument = Arrays.copyOf(currentLevelIsDocument, level * 2); |
| 201 |
} |
| 202 |
currentLevelIsDocument[level] = true; |
| 203 |
state = Content; |
| 204 |
} |
| 205 |
|
| 206 |
|
| 207 |
|
| 208 |
|
| 209 |
|
| 210 |
public void endDocument() throws XPathException { |
| 211 |
if (level == 0) { |
| 212 |
nextReceiver.endDocument(); |
| 213 |
} |
| 214 |
previousAtomic = false; |
| 215 |
level--; |
| 216 |
state = level < 0 ? Open : Content; |
| 217 |
} |
| 218 |
|
| 219 |
|
| 220 |
|
| 221 |
|
| 222 |
|
| 223 |
|
| 224 |
|
| 225 |
|
| 226 |
@Override |
| 227 |
public void setUnparsedEntity(String name, String systemID, String publicID) throws XPathException { |
| 228 |
nextReceiver.setUnparsedEntity(name, systemID, publicID); |
| 229 |
} |
| 230 |
|
| 231 |
|
| 232 |
|
| 233 |
|
| 234 |
|
| 235 |
|
| 236 |
|
| 237 |
|
| 238 |
|
| 239 |
|
| 240 |
|
| 241 |
public void characters(CharSequence s, Location locationId, int properties) throws XPathException { |
| 242 |
if (level >= 0) { |
| 243 |
previousAtomic = false; |
| 244 |
if (s == null) { |
| 245 |
return; |
| 246 |
} |
| 247 |
int len = s.length(); |
| 248 |
if (len == 0) { |
| 249 |
return; |
| 250 |
} |
| 251 |
if (state == StartTag) { |
| 252 |
startContent(); |
| 253 |
} |
| 254 |
} |
| 255 |
nextReceiver.characters(s, locationId, properties); |
| 256 |
} |
| 257 |
|
| 258 |
|
| 259 |
|
| 260 |
|
| 261 |
|
| 262 |
|
| 263 |
|
| 264 |
|
| 265 |
|
| 266 |
|
| 267 |
public void startElement(NodeName elemName, SchemaType typeCode, Location location, int properties) throws XPathException { |
| 268 |
|
| 269 |
level++; |
| 270 |
if (state == StartTag) { |
| 271 |
startContent(); |
| 272 |
} |
| 273 |
startElementProperties = properties; |
| 274 |
startElementLocationId = location.saveLocation(); |
| 275 |
pendingAttListSize = 0; |
| 276 |
pendingNSListSize = 0; |
| 277 |
pendingStartTag = elemName; |
| 278 |
|
| 279 |
elementIsInNullNamespace = null; |
| 280 |
declaresDefaultNamespace = false; |
| 281 |
currentSimpleType = typeCode; |
| 282 |
previousAtomic = false; |
| 283 |
if (currentLevelIsDocument.length < level + 1) { |
| 284 |
currentLevelIsDocument = Arrays.copyOf(currentLevelIsDocument, level * 2); |
| 285 |
} |
| 286 |
if (copyNamespacesStack.length < level + 1) { |
| 287 |
copyNamespacesStack = Arrays.copyOf(copyNamespacesStack, level * 2); |
| 288 |
} |
| 289 |
currentLevelIsDocument[level] = false; |
| 290 |
state = StartTag; |
| 291 |
} |
| 292 |
|
| 293 |
|
| 294 |
|
| 295 |
|
| 296 |
|
| 297 |
|
| 298 |
|
| 299 |
|
| 300 |
|
| 301 |
|
| 302 |
|
| 303 |
|
| 304 |
|
| 305 |
|
| 306 |
public void namespace(NamespaceBindingSet nsBindings, int properties) |
| 307 |
throws XPathException { |
| 308 |
|
| 309 |
if (nsBindings instanceof InScopeNamespaces) { |
| 310 |
copyNamespacesStack[level] = (InScopeNamespaces)nsBindings; |
| 311 |
if (level > 0 && copyNamespacesStack[level - 1] != null && |
| 312 |
copyNamespacesStack[level - 1].getElement().equals(((InScopeNamespaces)nsBindings).getElement())) { |
| 313 |
|
| 314 |
return; |
| 315 |
} |
| 316 |
} |
| 317 |
|
| 318 |
|
| 319 |
for (NamespaceBinding ns : nsBindings) { |
| 320 |
if (state != StartTag) { |
| 321 |
throw NoOpenStartTagException.makeNoOpenStartTagException( |
| 322 |
Type.NAMESPACE, |
| 323 |
ns.getPrefix(), |
| 324 |
hostLanguage, |
| 325 |
currentLevelIsDocument[level], |
| 326 |
startElementLocationId); |
| 327 |
} |
| 328 |
|
| 329 |
|
| 330 |
|
| 331 |
|
| 332 |
|
| 333 |
|
| 334 |
boolean rejectDuplicates = (properties & ReceiverOptions.REJECT_DUPLICATES) != 0; |
| 335 |
|
| 336 |
for (int i = 0; i < pendingNSListSize; i++) { |
| 337 |
if (ns.getPrefix().equals(pendingNSList[i].getPrefix())) { |
| 338 |
if (ns.getURI().equals(pendingNSList[i].getURI())) { |
| 339 |
return; |
| 340 |
} |
| 341 |
if (pendingNSList[i].isDefaultUndeclaration() || ns.isDefaultUndeclaration()) { |
| 342 |
|
| 343 |
pendingNSList[i] = ns; |
| 344 |
} else if (rejectDuplicates) { |
| 345 |
String prefix = ns.getPrefix(); |
| 346 |
String uri1 = ns.getURI(); |
| 347 |
String uri2 = pendingNSList[i].getURI(); |
| 348 |
XPathException err = new XPathException("Cannot create two namespace nodes with the same prefix mapped to different URIs (prefix=" + |
| 349 |
(prefix.isEmpty() ? "\"\"" : prefix) + ", URI=" + |
| 350 |
(uri1.isEmpty() ? "\"\"" : uri1) + ", URI=" + |
| 351 |
(uri2.isEmpty() ? "\"\"" : uri2) + ")"); |
| 352 |
err.setErrorCode(hostLanguage == Configuration.XSLT ? "XTDE0430" : "XQDY0102"); |
| 353 |
throw err; |
| 354 |
} else { |
| 355 |
|
| 356 |
return; |
| 357 |
} |
| 358 |
} |
| 359 |
} |
| 360 |
|
| 361 |
|
| 362 |
|
| 363 |
|
| 364 |
if (ns.getPrefix().isEmpty() && !ns.getURI().isEmpty()) { |
| 365 |
declaresDefaultNamespace = true; |
| 366 |
if (elementIsInNullNamespace == null) { |
| 367 |
elementIsInNullNamespace = pendingStartTag.hasURI(""); |
| 368 |
} |
| 369 |
if (elementIsInNullNamespace) { |
| 370 |
XPathException err = new XPathException("Cannot output a namespace node for the default namespace when the element is in no namespace"); |
| 371 |
err.setErrorCode(hostLanguage == Configuration.XSLT ? "XTDE0440" : "XQDY0102"); |
| 372 |
throw err; |
| 373 |
} |
| 374 |
} |
| 375 |
|
| 376 |
|
| 377 |
|
| 378 |
if (pendingNSListSize + 1 > pendingNSList.length) { |
| 379 |
pendingNSList = Arrays.copyOf(pendingNSList, pendingNSListSize * 2); |
| 380 |
} |
| 381 |
pendingNSList[pendingNSListSize++] = ns; |
| 382 |
previousAtomic = false; |
| 383 |
} |
| 384 |
} |
| 385 |
|
| 386 |
|
| 387 |
|
| 388 |
|
| 389 |
|
| 390 |
|
| 391 |
|
| 392 |
|
| 393 |
|
| 394 |
|
| 395 |
|
| 396 |
|
| 397 |
|
| 398 |
|
| 399 |
|
| 400 |
public void attribute(NodeName attName, SimpleType typeCode, CharSequence value, Location locationId, int properties) throws XPathException { |
| 401 |
|
| 402 |
if (level >= 0 && state != StartTag) { |
| 403 |
|
| 404 |
|
| 405 |
XPathException err = NoOpenStartTagException.makeNoOpenStartTagException( |
| 406 |
Type.ATTRIBUTE, |
| 407 |
attName.getDisplayName(), |
| 408 |
hostLanguage, |
| 409 |
currentLevelIsDocument[level], |
| 410 |
startElementLocationId); |
| 411 |
err.setLocator(locationId); |
| 412 |
throw err; |
| 413 |
} |
| 414 |
|
| 415 |
|
| 416 |
|
| 417 |
|
| 418 |
if (level >= 0 && ((properties & ReceiverOptions.NOT_A_DUPLICATE)==0)) { |
| 419 |
for (int a = 0; a < pendingAttListSize; a++) { |
| 420 |
if (pendingAttCode[a].equals(attName)) { |
| 421 |
if (hostLanguage == Configuration.XSLT) { |
| 422 |
pendingAttType[a] = typeCode; |
| 423 |
pendingAttValue[a] = value.toString(); |
| 424 |
|
| 425 |
pendingAttLocation[a] = locationId; |
| 426 |
pendingAttProp[a] = properties; |
| 427 |
return; |
| 428 |
} else { |
| 429 |
XPathException err = new XPathException("Cannot create an element having two attributes with the same name: " + |
| 430 |
Err.wrap(attName.getDisplayName(), Err.ATTRIBUTE)); |
| 431 |
err.setErrorCode("XQDY0025"); |
| 432 |
throw err; |
| 433 |
} |
| 434 |
} |
| 435 |
} |
| 436 |
} |
| 437 |
|
| 438 |
|
| 439 |
|
| 440 |
|
| 441 |
|
| 442 |
if (level == 0 && !typeCode.equals(BuiltInAtomicType.UNTYPED_ATOMIC) && currentLevelIsDocument[0] ) { |
| 443 |
|
| 444 |
|
| 445 |
if (typeCode.isNamespaceSensitive()) { |
| 446 |
XPathException err = new XPathException("Cannot copy attributes whose type is namespace-sensitive (QName or NOTATION): " + |
| 447 |
Err.wrap(attName.getDisplayName(), Err.ATTRIBUTE)); |
| 448 |
err.setErrorCode(hostLanguage == Configuration.XSLT ? "XTTE0950" : "XQTY0086"); |
| 449 |
throw err; |
| 450 |
} |
| 451 |
} |
| 452 |
|
| 453 |
|
| 454 |
if (level < 0) { |
| 455 |
nextReceiver.attribute(attName, typeCode, value, locationId, properties); |
| 456 |
} |
| 457 |
|
| 458 |
|
| 459 |
|
| 460 |
if (pendingAttListSize >= pendingAttCode.length) { |
| 461 |
pendingAttCode = Arrays.copyOf(pendingAttCode, pendingAttListSize * 2); |
| 462 |
pendingAttType = Arrays.copyOf(pendingAttType, pendingAttListSize * 2); |
| 463 |
pendingAttValue = Arrays.copyOf(pendingAttValue, pendingAttListSize * 2); |
| 464 |
pendingAttLocation = Arrays.copyOf(pendingAttLocation, pendingAttListSize * 2); |
| 465 |
pendingAttProp = Arrays.copyOf(pendingAttProp, pendingAttListSize * 2); |
| 466 |
} |
| 467 |
|
| 468 |
pendingAttCode[pendingAttListSize] = attName; |
| 469 |
pendingAttType[pendingAttListSize] = typeCode; |
| 470 |
pendingAttValue[pendingAttListSize] = value.toString(); |
| 471 |
pendingAttLocation[pendingAttListSize] = locationId; |
| 472 |
pendingAttProp[pendingAttListSize] = properties; |
| 473 |
pendingAttListSize++; |
| 474 |
previousAtomic = false; |
| 475 |
} |
| 476 |
|
| 477 |
|
| 478 |
|
| 479 |
|
| 480 |
|
| 481 |
|
| 482 |
|
| 483 |
|
| 484 |
|
| 485 |
|
| 486 |
|
| 487 |
|
| 488 |
|
| 489 |
|
| 490 |
|
| 491 |
|
| 492 |
|
| 493 |
|
| 494 |
|
| 495 |
private NodeName checkProposedPrefix(NodeName nodeName, int seq) throws XPathException { |
| 496 |
NamespaceBinding binding = nodeName.getNamespaceBinding(); |
| 497 |
String nsprefix = binding.getPrefix(); |
| 498 |
|
| 499 |
for (int i = 0; i < pendingNSListSize; i++) { |
| 500 |
if (nsprefix.equals(pendingNSList[i].getPrefix())) { |
| 501 |
|
| 502 |
if (binding.getURI().equals(pendingNSList[i].getURI())) { |
| 503 |
|
| 504 |
return nodeName; |
| 505 |
} else { |
| 506 |
String prefix = getSubstitutePrefix(binding, seq); |
| 507 |
NodeName newName = new FingerprintedQName(prefix, nodeName.getURI(), nodeName.getLocalPart()); |
| 508 |
namespace(newName.getNamespaceBinding(), 0); |
| 509 |
return newName; |
| 510 |
} |
| 511 |
} |
| 512 |
} |
| 513 |
|
| 514 |
if (seq > 0 && nsprefix.isEmpty()) { |
| 515 |
|
| 516 |
|
| 517 |
String prefix = getSubstitutePrefix(binding, seq); |
| 518 |
NodeName newName = new FingerprintedQName(prefix, nodeName.getURI(), nodeName.getLocalPart()); |
| 519 |
namespace(newName.getNamespaceBinding(), 0); |
| 520 |
return newName; |
| 521 |
} |
| 522 |
namespace(binding, 0); |
| 523 |
return nodeName; |
| 524 |
} |
| 525 |
|
| 526 |
|
| 527 |
|
| 528 |
|
| 529 |
|
| 530 |
|
| 531 |
|
| 532 |
|
| 533 |
|
| 534 |
|
| 535 |
|
| 536 |
|
| 537 |
private String getSubstitutePrefix(NamespaceBinding nscode, int seq) { |
| 538 |
if (nscode.getURI().equals(NamespaceConstant.XML)) { |
| 539 |
return "xml"; |
| 540 |
} |
| 541 |
return nscode.getPrefix() + '_' + seq; |
| 542 |
} |
| 543 |
|
| 544 |
|
| 545 |
|
| 546 |
|
| 547 |
|
| 548 |
public void endElement() throws XPathException { |
| 549 |
|
| 550 |
if (state == StartTag) { |
| 551 |
startContent(); |
| 552 |
} else { |
| 553 |
|
| 554 |
pendingStartTag = null; |
| 555 |
} |
| 556 |
|
| 557 |
|
| 558 |
|
| 559 |
nextReceiver.endElement(); |
| 560 |
level--; |
| 561 |
previousAtomic = false; |
| 562 |
state = level < 0 ? Open : Content; |
| 563 |
} |
| 564 |
|
| 565 |
|
| 566 |
|
| 567 |
|
| 568 |
|
| 569 |
public void comment(CharSequence comment, Location locationId, int properties) throws XPathException { |
| 570 |
if (level >= 0) { |
| 571 |
if (state == StartTag) { |
| 572 |
startContent(); |
| 573 |
} |
| 574 |
previousAtomic = false; |
| 575 |
} |
| 576 |
nextReceiver.comment(comment, locationId, properties); |
| 577 |
} |
| 578 |
|
| 579 |
|
| 580 |
|
| 581 |
|
| 582 |
|
| 583 |
public void processingInstruction(String target, CharSequence data, Location locationId, int properties) throws XPathException { |
| 584 |
if (level >= 0) { |
| 585 |
if (state == StartTag) { |
| 586 |
startContent(); |
| 587 |
} |
| 588 |
previousAtomic = false; |
| 589 |
} |
| 590 |
nextReceiver.processingInstruction(target, data, locationId, properties); |
| 591 |
} |
| 592 |
|
| 593 |
|
| 594 |
|
| 595 |
|
| 596 |
|
| 597 |
|
| 598 |
|
| 599 |
|
| 600 |
|
| 601 |
|
| 602 |
|
| 603 |
|
| 604 |
public void append(Item item, Location locationId, int copyNamespaces) throws XPathException { |
| 605 |
|
| 606 |
|
| 607 |
|
| 608 |
if (level >= 0) { |
| 609 |
decompose(item, locationId, copyNamespaces); |
| 610 |
} else { |
| 611 |
nextReceiver.append(item, locationId, copyNamespaces); |
| 612 |
} |
| 613 |
} |
| 614 |
|
| 615 |
|
| 616 |
|
| 617 |
|
| 618 |
|
| 619 |
public void close() throws XPathException { |
| 620 |
|
| 621 |
nextReceiver.close(); |
| 622 |
previousAtomic = false; |
| 623 |
state = Final; |
| 624 |
} |
| 625 |
|
| 626 |
|
| 627 |
|
| 628 |
|
| 629 |
|
| 630 |
public void startContent() throws XPathException { |
| 631 |
|
| 632 |
if (state != StartTag) { |
| 633 |
|
| 634 |
|
| 635 |
return; |
| 636 |
} |
| 637 |
|
| 638 |
NodeName elcode = checkProposedPrefix(pendingStartTag, 0); |
| 639 |
int props = startElementProperties | ReceiverOptions.NAMESPACE_OK; |
| 640 |
nextReceiver.startElement(elcode, currentSimpleType, startElementLocationId, props); |
| 641 |
|
| 642 |
for (int a = 0; a < pendingAttListSize; a++) { |
| 643 |
NodeName attcode = pendingAttCode[a]; |
| 644 |
if (!attcode.hasURI("")) { |
| 645 |
attcode = checkProposedPrefix(attcode, a + 1); |
| 646 |
pendingAttCode[a] = attcode; |
| 647 |
} |
| 648 |
} |
| 649 |
|
| 650 |
for (int n = 0; n < pendingNSListSize; n++) { |
| 651 |
nextReceiver.namespace(pendingNSList[n], 0); |
| 652 |
} |
| 653 |
|
| 654 |
for (int a = 0; a < pendingAttListSize; a++) { |
| 655 |
nextReceiver.attribute(pendingAttCode[a], |
| 656 |
pendingAttType[a], |
| 657 |
pendingAttValue[a], |
| 658 |
pendingAttLocation[a], |
| 659 |
pendingAttProp[a]); |
| 660 |
} |
| 661 |
|
| 662 |
nextReceiver.startContent(); |
| 663 |
|
| 664 |
pendingAttListSize = 0; |
| 665 |
pendingNSListSize = 0; |
| 666 |
|
| 667 |
previousAtomic = false; |
| 668 |
state = Content; |
| 669 |
} |
| 670 |
|
| 671 |
|
| 672 |
|
| 673 |
|
| 674 |
|
| 675 |
|
| 676 |
|
| 677 |
|
| 678 |
|
| 679 |
public boolean usesTypeAnnotations() { |
| 680 |
return nextReceiver.usesTypeAnnotations(); |
| 681 |
} |
| 682 |
|
| 683 |
public boolean isReadyForGrafting() { |
| 684 |
Receiver r2 = getReceiver(); |
| 685 |
if (r2 instanceof NamespaceReducer) { |
| 686 |
if (!((NamespaceReducer) r2).isDisinheritingNamespaces()) { |
| 687 |
Receiver r3 = ((NamespaceReducer) r2).getNextReceiver(); |
| 688 |
return r3 instanceof TinyBuilder && |
| 689 |
((state == StartTag && |
| 690 |
(startElementProperties & ReceiverOptions.DISINHERIT_NAMESPACES) == 0) |
| 691 |
|| ((TinyBuilder) r3).isPositionedAtElement()); |
| 692 |
} |
| 693 |
} |
| 694 |
return false; |
| 695 |
} |
| 696 |
|
| 697 |
public void graftElementNode(TinyElementImpl elementNode, int copyOptions) throws XPathException { |
| 698 |
NamespaceReducer r2 = (NamespaceReducer)getReceiver(); |
| 699 |
TinyBuilder target = (TinyBuilder)r2.getNextReceiver(); |
| 700 |
beforeBulkCopy(); |
| 701 |
boolean copyNamespaces = CopyOptions.includes(copyOptions, CopyOptions.ALL_NAMESPACES); |
| 702 |
target.graft(elementNode, copyNamespaces); |
| 703 |
afterBulkCopy(); |
| 704 |
} |
| 705 |
|
| 706 |
public boolean isReadyForBulkCopy() { |
| 707 |
Receiver r2 = getReceiver(); |
| 708 |
if (r2 instanceof NamespaceReducer) { |
| 709 |
if (!((NamespaceReducer) r2).isDisinheritingNamespaces()) { |
| 710 |
Receiver r3 = ((NamespaceReducer) r2).getNextReceiver(); |
| 711 |
return r3 instanceof TinyBuilder && |
| 712 |
((state == StartTag && |
| 713 |
(startElementProperties & ReceiverOptions.DISINHERIT_NAMESPACES) == 0) |
| 714 |
|| ((TinyBuilder) r3).isPositionedAtElement()); |
| 715 |
} |
| 716 |
} |
| 717 |
return false; |
| 718 |
} |
| 719 |
|
| 720 |
public void bulkCopyElementNode(TinyElementImpl elementNode, int copyOptions) throws XPathException { |
| 721 |
NamespaceReducer r2 = (NamespaceReducer) getReceiver(); |
| 722 |
TinyBuilder target = (TinyBuilder) r2.getNextReceiver(); |
| 723 |
beforeBulkCopy(); |
| 724 |
boolean copyNamespaces = CopyOptions.includes(copyOptions, CopyOptions.ALL_NAMESPACES); |
| 725 |
target.bulkCopy(elementNode, copyNamespaces); |
| 726 |
afterBulkCopy(); |
| 727 |
} |
| 728 |
|
| 729 |
private void beforeBulkCopy() throws XPathException { |
| 730 |
level++; |
| 731 |
if (state == StartTag) { |
| 732 |
startContent(); |
| 733 |
} |
| 734 |
} |
| 735 |
|
| 736 |
private void afterBulkCopy() { |
| 737 |
level--; |
| 738 |
previousAtomic = false; |
| 739 |
} |
| 740 |
} |
| 741 |
|