/** * Determine whether the wrapped document contains any xml:space="preserve" attributes. If it * does, we will look for them when stripping individual nodes. It's more efficient to scan * the document in advance checking for xml:space attributes than to look for them every time * we hit a whitespace text node. */ private static boolean findPreserveSpace(DocumentInfo doc) { AxisIterator iter = doc.iterateAxis(Axis.DESCENDANT, NodeKindTest.ELEMENT); while (true) { NodeInfo node = (NodeInfo)iter.next(); if (node == null) { return false; } String val = node.getAttributeValue(StandardNames.XML_SPACE); if ("preserve".equals(val)) { return true; } } }
/** * Get the unparsed entity with a given name * * @param name the name of the entity * @return if the entity exists, return an array of two Strings, the first * holding the system ID of the entity, the second holding the public * ID if there is one, or null if not. If the entity does not exist, * return null. */ public String[] getUnparsedEntity(String name) { return ((DocumentInfo)original).getUnparsedEntity(name); }
/** * Get the URI for a given document node, if it is present in the pool. This supports the * document-uri() function. * @param doc The document node * @return The uri of the document node, if present in the pool, or the systemId of the document node otherwise */ public String getDocumentURI(NodeInfo doc) { Iterator iter = documentNameMap.keySet().iterator(); while (iter.hasNext()) { String uri = (String)iter.next(); if (find(uri).isSameNodeInfo(doc)) { return uri; } } return null; }
/** * Get the element with a given ID, if any * @param id the required ID value * @return the element with the given ID value, or null if there is none. */ public NodeInfo selectID(String id) { NodeInfo n = ((DocumentInfo)node).selectID(id); if (n==null) { return null; } else { return makeWrapper(n, this, null); } }
String systemId = ((DocumentInfo)obj).getSystemId(); try { if (systemId != null && new URI(systemId).isAbsolute()) {
/** * Build a document, using specified options for parsing and building. This method always * constructs a new tree, it never wraps an existing document (regardless of anything in * the parseOptions) * * @param source the source of the document to be constructed. If this is an * AugmentedSource, then any parser options contained in the AugmentedSource take precedence * over options specified in the parseOptions argument. * @param parseOptions options for parsing and constructing the document. Any options that * are not explicitly set in parseOptions default first to the values supplied in the source * argument if it is an AugmentedSource, and then to the values set in this Configuration. * The supplied parseOptions object is not modified. * @return the document node of the constructed document * @throws XPathException if parsing fails, or if the Source represents a node other than * a document node * @since 9.2. In 9.7 the method is retained to provide a semblance of backwards compatibility for common * use cases; to achieve this, DocumentInfo is changed from an interface implemented by all document * nodes, to a wrapper object around the actual root of the tree. * @deprecated since 9.7: use {@link #buildDocumentTree(Source, ParseOptions)}. */ public DocumentInfo buildDocument(Source source, ParseOptions parseOptions) throws XPathException { TreeInfo tree = buildDocumentTree(source, parseOptions); NodeInfo root = tree.getRootNode(); return new DocumentInfo(root); }
/** * Get a character string that uniquely identifies this node * @param buffer to contain the generated ID */ public void generateId(FastStringBuffer buffer) { getDocumentRoot().generateId(buffer); buffer.append("e"); buffer.append(Integer.toString(sequence)); }
/** * Get the configuration */ public Configuration getConfiguration() { return getDocumentRoot().getConfiguration(); }
/** * Get the document number of the document containing this node. For a free-standing * orphan node, just return the hashcode. */ public int getDocumentNumber() { return getDocumentRoot().getDocumentNumber(); }
/** * Get the NamePool */ public NamePool getNamePool() { return getDocumentRoot().getNamePool(); }
/** * Get the element with a given ID, if any * @param id the required ID value * @return the element with the given ID value, or null if there is none. */ public NodeInfo selectID(String id) { NodeInfo n = ((DocumentInfo)node).selectID(id); if (n==null) { return null; } else { return makeWrapper(n, this, null); } }
String systemId = ((DocumentInfo)obj).getSystemId(); try { if (systemId != null && new URI(systemId).isAbsolute()) {
/** * Build a document, using specified options for parsing and building. This method always * constructs a new tree, it never wraps an existing document (regardless of anything in * the parseOptions) * * @param source the source of the document to be constructed. If this is an * AugmentedSource, then any parser options contained in the AugmentedSource take precedence * over options specified in the parseOptions argument. * @param parseOptions options for parsing and constructing the document. Any options that * are not explicitly set in parseOptions default first to the values supplied in the source * argument if it is an AugmentedSource, and then to the values set in this Configuration. * The supplied parseOptions object is not modified. * @return the document node of the constructed document * @throws XPathException if parsing fails, or if the Source represents a node other than * a document node * @since 9.2. In 9.7 the method is retained to provide a semblance of backwards compatibility for common * use cases; to achieve this, DocumentInfo is changed from an interface implemented by all document * nodes, to a wrapper object around the actual root of the tree. * @deprecated since 9.7: use {@link #buildDocumentTree(Source, ParseOptions)}. */ public DocumentInfo buildDocument(Source source, ParseOptions parseOptions) throws XPathException { TreeInfo tree = buildDocumentTree(source, parseOptions); NodeInfo root = tree.getRootNode(); return new DocumentInfo(root); }
/** * Get a character string that uniquely identifies this node * @param buffer to contain the generated ID */ public void generateId(FastStringBuffer buffer) { getDocumentRoot().generateId(buffer); buffer.append("e"); buffer.append(Integer.toString(sequence)); }
/** * Get the configuration */ public Configuration getConfiguration() { return getDocumentRoot().getConfiguration(); }
/** * Get the document number of the document containing this node. For a free-standing * orphan node, just return the hashcode. */ public int getDocumentNumber() { return getDocumentRoot().getDocumentNumber(); }
/** * Get the NamePool */ public NamePool getNamePool() { return getDocumentRoot().getNamePool(); }
/** * Determine whether the wrapped document contains any xml:space="preserve" attributes. If it * does, we will look for them when stripping individual nodes. It's more efficient to scan * the document in advance checking for xml:space attributes than to look for them every time * we hit a whitespace text node. */ private static boolean findPreserveSpace(DocumentInfo doc) { AxisIterator iter = doc.iterateAxis(Axis.DESCENDANT, NodeKindTest.ELEMENT); while (true) { NodeInfo node = (NodeInfo)iter.next(); if (node == null) { return false; } String val = node.getAttributeValue(StandardNames.XML_SPACE); if ("preserve".equals(val)) { return true; } } }
/** * Get the element with a given ID, if any * @param id the required ID value * @return the element with the given ID value, or null if there is none. */ public NodeInfo selectID(String id) { NodeInfo n = ((DocumentInfo)node).selectID(id); if (n==null) { return null; } else { return makeWrapper(n, this, null); } }
/** * Get the unparsed entity with a given name * @param name the name of the entity */ public String[] getUnparsedEntity(String name) { return ((DocumentInfo)node).getUnparsedEntity(name); }