private Supplier<NodeInfo> nodeSupplier(short nodeKind, NodeName name, CharSequence value) { return () -> { Orphan o = new Orphan(getConfiguration()); o.setNodeKind(nodeKind); if (name != null) { o.setNodeName(name); } o.setStringValue(value); return o; }; }
/** * Determine the relative position of this node and another node, in document order. * The other node will always be in the same document. * * @param other The other node, whose position is to be compared with this node * @return -1 if this node precedes the other node, +1 if it follows the other * node, or 0 if they are the same node. (In this case, isSameNode() will always * return true, and the two nodes will produce the same result for generateId()) */ public int compareOrder(/*@NotNull*/ NodeInfo other) { // are they the same node? if (this.equals(other)) { return 0; } return this.hashCode() < other.hashCode() ? -1 : +1; }
/** * Get the Base URI for the node, that is, the URI used for resolving a relative URI contained * in the node. This will be the same as the System ID unless xml:base has been used. */ /*@Nullable*/ public String getBaseURI() { if (kind == Type.PROCESSING_INSTRUCTION) { return getSystemId(); } else { return null; } }
@Override public void characters(CharSequence s, Location locationId, int properties) throws XPathException { if (level == 0) { Orphan o = new Orphan(getConfiguration()); o.setNodeKind(Type.TEXT); o.setStringValue(s.toString()); write(o); } else { if (s.length() > 0) { if (inStartTag) { startContent(); } outputter.characters(s, locationId, properties); } } previousAtomic = false; }
Orphan o = new Orphan(controller.getConfiguration()); o.setNodeKind(Type.TEXT); o.setStringValue(val); if ((options & ReceiverOptions.DISABLE_ESCAPING) != 0) { o.setDisableOutputEscaping(true);
if (schemaType != null) { ValidationFailure err = schemaType.validateContent( orphan.getStringValueCS(), DummyNamespaceResolver.getInstance(), rules); if (err != null) { err.setMessage("Attribute value " + Err.wrap(orphan.getStringValueCS(), Err.VALUE) + " does not the match the required type " + schemaType.getDescription() + ". " + throw err.makeException(); orphan.setTypeAnnotation(schemaType); if (schemaType.isNamespaceSensitive()) { throw new XPathException("Cannot validate a parentless attribute whose content is namespace-sensitive", "XTTE1545"); assert controller != null; SimpleType ann = controller.getConfiguration().validateAttribute( NameOfNode.makeName(orphan).getStructuredQName(), orphan.getStringValueCS(), validationAction); orphan.setTypeAnnotation(ann); } catch (ValidationException e) { XPathException err = XPathException.makeXPathException(e);
/** * Ask whether this node has the is-idref property * * @return true if the node is an IDREF or IDREFS element or attribute */ public boolean isIdref() { return isOption(ReceiverOptions.IS_IDREF); }
/** * Get a character string that uniquely identifies this node. * Note: a.isSameNode(b) if and only if generateId(a)==generateId(b) * * @param buffer a buffer, into which will be placed * a string that uniquely identifies this node, within this * document. The calling code prepends information to make the result * unique across all documents. */ public void generateId(/*@NotNull*/ FastStringBuffer buffer) { buffer.append('Q'); buffer.append(Integer.toString(hashCode())); }
/** * Get the typed value. * @return the typed value. * @since 8.5 */ public AtomicSequence atomize() throws XPathException { switch (getNodeKind()) { case Type.COMMENT: case Type.PROCESSING_INSTRUCTION: return new StringValue(stringValue); case Type.TEXT: case Type.DOCUMENT: case Type.NAMESPACE: return new UntypedAtomicValue(stringValue); default: if (typeAnnotation == null || typeAnnotation == Untyped.getInstance() || typeAnnotation == BuiltInAtomicType.UNTYPED_ATOMIC) { return new UntypedAtomicValue(stringValue); } else { return typeAnnotation.atomize(this); } } }
if (node instanceof Orphan && ((Orphan) node).isDisableOutputEscaping()) {
@Override public void comment(CharSequence comment, Location locationId, int properties) throws XPathException { if (inStartTag) { startContent(); } if (level == 0) { Orphan o = new Orphan(getConfiguration()); o.setNodeKind(Type.COMMENT); o.setStringValue(comment); write(o); } else { outputter.comment(comment, locationId, properties); } previousAtomic = false; }
Orphan o = new Orphan(controller.getConfiguration()); o.setNodeKind(Type.TEXT); o.setStringValue(val); if ((options & ReceiverOptions.DISABLE_ESCAPING) != 0) { o.setDisableOutputEscaping(true);
if (schemaType != null) { ValidationFailure err = schemaType.validateContent( orphan.getStringValueCS(), DummyNamespaceResolver.getInstance(), rules); if (err != null) { err.setMessage("Attribute value " + Err.wrap(orphan.getStringValueCS(), Err.VALUE) + " does not the match the required type " + schemaType.getDescription() + ". " + throw err.makeException(); orphan.setTypeAnnotation(schemaType); if (schemaType.isNamespaceSensitive()) { throw new XPathException("Cannot validate a parentless attribute whose content is namespace-sensitive", "XTTE1545"); assert controller != null; SimpleType ann = controller.getConfiguration().validateAttribute( NameOfNode.makeName(orphan).getStructuredQName(), orphan.getStringValueCS(), validationAction); orphan.setTypeAnnotation(ann); } catch (ValidationException e) { XPathException err = XPathException.makeXPathException(e);
/** * Ask whether the node has the disable-output-escaping property * @return true if the node has the disable-output-escaping property */ public boolean isDisableOutputEscaping() { return isOption(ReceiverOptions.DISABLE_ESCAPING); }
/** * Get a character string that uniquely identifies this node. * Note: a.isSameNode(b) if and only if generateId(a)==generateId(b) * * @param buffer a buffer, into which will be placed * a string that uniquely identifies this node, within this * document. The calling code prepends information to make the result * unique across all documents. */ public void generateId(/*@NotNull*/ FastStringBuffer buffer) { buffer.append('Q'); buffer.append(Integer.toString(hashCode())); }
/** * Get the typed value. * @return the typed value. * @since 8.5 */ public AtomicSequence atomize() throws XPathException { switch (getNodeKind()) { case Type.COMMENT: case Type.PROCESSING_INSTRUCTION: return new StringValue(stringValue); case Type.TEXT: case Type.DOCUMENT: case Type.NAMESPACE: return new UntypedAtomicValue(stringValue); default: if (typeAnnotation == null || typeAnnotation == Untyped.getInstance() || typeAnnotation == BuiltInAtomicType.UNTYPED_ATOMIC) { return new UntypedAtomicValue(stringValue); } else { return typeAnnotation.atomize(this); } } }
if (node instanceof Orphan && ((Orphan) node).isDisableOutputEscaping()) {
private Supplier<NodeInfo> nodeSupplier(short nodeKind, NodeName name, CharSequence value) { return () -> { Orphan o = new Orphan(getConfiguration()); o.setNodeKind(nodeKind); if (name != null) { o.setNodeName(name); } o.setStringValue(value); return o; }; }
@Override public void comment(CharSequence comment, Location locationId, int properties) throws XPathException { if (inStartTag) { startContent(); } if (level == 0) { Orphan o = new Orphan(getConfiguration()); o.setNodeKind(Type.COMMENT); o.setStringValue(comment); write(o); } else { outputter.comment(comment, locationId, properties); } previousAtomic = false; }
/** * Determine the relative position of this node and another node, in document order. * The other node will always be in the same document. * * @param other The other node, whose position is to be compared with this node * @return -1 if this node precedes the other node, +1 if it follows the other * node, or 0 if they are the same node. (In this case, isSameNode() will always * return true, and the two nodes will produce the same result for generateId()) */ public int compareOrder(/*@NotNull*/ NodeInfo other) { // are they the same node? if (this.equals(other)) { return 0; } return this.hashCode() < other.hashCode() ? -1 : +1; }