Class NodeImpl
java.lang.Object
com.icl.saxon.om.AbstractNode
com.icl.saxon.tree.NodeImpl
- All Implemented Interfaces:
NodeInfo, DOMLocator, Source, SourceLocator, Node
- Direct Known Subclasses:
AttributeImpl, CommentImpl, NamespaceImpl, ParentNodeImpl, ProcInstImpl, TextImpl
A node in the XML parse tree representing an XML element, character content, or attribute.
This is the top-level class in the implementation class hierarchy; it essentially contains all those methods that can be defined using other primitive methods, without direct access to data.
- Author:
- Michael H. Kay
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static NodeInfo[]protected intprotected ParentNodeImplFields inherited from class AbstractNode
NODE_LETTERFields inherited from interface Node
ATTRIBUTE_NODE, CDATA_SECTION_NODE, COMMENT_NODE, DOCUMENT_FRAGMENT_NODE, DOCUMENT_NODE, DOCUMENT_POSITION_CONTAINED_BY, DOCUMENT_POSITION_CONTAINS, DOCUMENT_POSITION_DISCONNECTED, DOCUMENT_POSITION_FOLLOWING, DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC, DOCUMENT_POSITION_PRECEDING, DOCUMENT_TYPE_NODE, ELEMENT_NODE, ENTITY_NODE, ENTITY_REFERENCE_NODE, NOTATION_NODE, PROCESSING_INSTRUCTION_NODE, TEXT_NODE -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfinal intcompareOrder(NodeInfo other) Determine the relative position of this node and another node, in document order.Get a character string that uniquely identifies this node within this document (The calling code will prepend a document identifier)Return aNamedNodeMapcontaining the attributes of this node (if it is anElement) ornullotherwise.getAttributeValue(int fingerprint) Get the value of a given attribute of this nodegetAttributeValue(String uri, String localName) Find the value of a given attribute of this node.Get the base URI for the node.Return aNodeListthat contains all children of this node.Get the display name of this node.Get the outermost element.Get the root (document) nodegetEnumeration(byte axisNumber, NodeTest nodeTest) Return an enumeration over the nodes reached by the given axis from this nodeintGet the fingerprint of the node.Get first child - default implementation used for leaf nodesGet last child - default implementation used for leaf nodesintGet the line number of the node within its source document entityGet the local name of this node.intGet the nameCode of the node.Get the NamePoolgetNextInDocument(NodeImpl anchor) Get the next node in document orderGet next sibling nodeGet the node corresponding to this javax.xml.transform.dom.DOMLocatorfinal NodeInfoFind the parent node of this node.Get the prefix part of the name of this node.Get the previous node in document orderGet the previous sibling of the nodeprotected longGet the node sequence number (in document order).Get the system ID for the node.getURI()Get the URI part of the name of this node.booleanReturns whether this node (if it is an element) has any attributes.booleanDetermine whether the node has any children.booleanisSameNodeInfo(NodeInfo other) Determine whether this is the same node as another nodevoidoutputNamespaceNodes(Outputter out, boolean includeAncestors) Output all namespace nodes associated with this element.voidRemove this node from the tree.voidsetSystemId(String uri) Set the system ID of this node.Methods inherited from class AbstractNode
appendChild, appendData, cloneNode, compareDocumentPosition, copyStringValue, createAttribute, createAttributeNS, createCDATASection, createComment, createDocumentFragment, createElement, createElementNS, createEntityReference, createProcessingInstruction, createTextNode, deleteData, disallowUpdate, getAttribute, getAttributeNode, getAttributeNodeNS, getAttributeNS, getColumnNumber, getData, getDoctype, getElementById, getElementsByTagName, getElementsByTagNameNS, getFeature, getImplementation, getLength, getName, getNamespaceURI, getNodeName, getNodeValue, getOwnerDocument, getOwnerElement, getParentNode, getPublicId, getSchemaTypeInfo, getSpecified, getTagName, getTextContent, getUserData, getValue, getWholeText, hasAttribute, hasAttributeNS, importNode, insertBefore, insertData, isDefaultNamespace, isElementContentWhitespace, isEqualNode, isId, isSameNode, isSupported, lookupNamespaceURI, lookupPrefix, normalize, removeAttribute, removeAttributeNode, removeAttributeNS, removeChild, replaceChild, replaceData, replaceWholeText, setAttributeNode, setAttributeNodeNS, setAttributeNS, setData, setIdAttribute, setIdAttributeNode, setIdAttributeNS, setNodeValue, setPrefix, setTextContent, setUserData, setValue, splitText, substringData, supportsMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface Node
getNodeTypeMethods inherited from interface NodeInfo
copy, getNodeType, getStringValue
-
Field Details
-
emptyArray
-
parent
-
index
protected int index
-
-
Constructor Details
-
NodeImpl
public NodeImpl()
-
-
Method Details
-
setSystemId
Set the system ID of this node. This method is provided so that a NodeInfo implements the javax.xml.transform.Source interface, allowing a node to be used directly as the Source of a transformation -
isSameNodeInfo
Determine whether this is the same node as another node- Specified by:
isSameNodeInfoin interfaceNodeInfo- Specified by:
isSameNodeInfoin classAbstractNode- Returns:
- true if this Node object and the supplied Node object represent the same node in the tree.
-
getNameCode
public int getNameCode()Get the nameCode of the node. This is used to locate the name in the NamePool- Specified by:
getNameCodein interfaceNodeInfo- Specified by:
getNameCodein classAbstractNode- See Also:
-
getFingerprint
public int getFingerprint()Get the fingerprint of the node. This is used to compare whether two nodes have equivalent names. Return -1 for a node with no name.- Specified by:
getFingerprintin interfaceNodeInfo- Specified by:
getFingerprintin classAbstractNode
-
generateId
Get a character string that uniquely identifies this node within this document (The calling code will prepend a document identifier)- Specified by:
generateIdin interfaceNodeInfo- Specified by:
generateIdin classAbstractNode- Returns:
- a string.
-
getOriginatingNode
Get the node corresponding to this javax.xml.transform.dom.DOMLocator- Specified by:
getOriginatingNodein interfaceDOMLocator- Overrides:
getOriginatingNodein classAbstractNode
-
getSystemId
Get the system ID for the node. Default implementation for child nodes.- Specified by:
getSystemIdin interfaceNodeInfo- Specified by:
getSystemIdin interfaceSource- Specified by:
getSystemIdin interfaceSourceLocator- Specified by:
getSystemIdin classAbstractNode- Returns:
- the System Identifier of the entity in the source document containing the node, or null if not known. Note this is not the same as the base URI: the base URI can be modified by xml:base, but the system ID cannot.
-
getBaseURI
Get the base URI for the node. Default implementation for child nodes.- Specified by:
getBaseURIin interfaceNode- Specified by:
getBaseURIin interfaceNodeInfo- Specified by:
getBaseURIin classAbstractNode
-
getSequenceNumber
protected long getSequenceNumber()Get the node sequence number (in document order). Sequence numbers are monotonic but not consecutive. In the current implementation, parent nodes (elements and roots) have a zero least-significant word, while namespaces, attributes, text nodes, comments, and PIs have the top word the same as their owner and the bottom half reflecting their relative position. This is the default implementation for child nodes. -
compareOrder
Determine the relative position of this node and another node, in document order. The other node will always be in the same document.- Specified by:
compareOrderin interfaceNodeInfo- Specified by:
compareOrderin classAbstractNode- Parameters:
other- The other node, whose position is to be compared with this node- Returns:
- -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())
-
getNamePool
Get the NamePool -
getPrefix
Get the prefix part of the name of this node. This is the name before the ":" if any. -
getURI
Get the URI part of the name of this node. This is the URI corresponding to the prefix, or the URI of the default namespace if appropriate.- Specified by:
getURIin interfaceNodeInfo- Specified by:
getURIin classAbstractNode- Returns:
- The URI of the namespace of this node. For the default namespace, return an empty string. For an unnamed node, return null.
-
getDisplayName
Get the display name of this node. For elements and attributes this is [prefix:]localname. For unnamed nodes, it is an empty string.- Specified by:
getDisplayNamein interfaceNodeInfo- Overrides:
getDisplayNamein classAbstractNode- Returns:
- The display name of this node. For a node with no name, return an empty string.
-
getLocalName
Get the local name of this node.- Specified by:
getLocalNamein interfaceNode- Specified by:
getLocalNamein interfaceNodeInfo- Specified by:
getLocalNamein classAbstractNode- Returns:
- The local name of this node. For a node with no name, return an empty string.
-
getLineNumber
public int getLineNumber()Get the line number of the node within its source document entity- Specified by:
getLineNumberin interfaceNodeInfo- Specified by:
getLineNumberin interfaceSourceLocator- Overrides:
getLineNumberin classAbstractNode- Returns:
- the line number of the node in its original source document; or -1 if not available
-
getParent
Find the parent node of this node.- Specified by:
getParentin interfaceNodeInfo- Specified by:
getParentin classAbstractNode- Returns:
- The Node object describing the containing element or root node.
-
getPreviousSibling
Get the previous sibling of the node- Specified by:
getPreviousSiblingin interfaceNode- Overrides:
getPreviousSiblingin classAbstractNode- Returns:
- The previous sibling node. Returns null if the current node is the first child of its parent.
-
getNextSibling
Get next sibling node- Specified by:
getNextSiblingin interfaceNode- Overrides:
getNextSiblingin classAbstractNode- Returns:
- The next sibling node of the required type. Returns null if the current node is the last child of its parent.
-
getFirstChild
Get first child - default implementation used for leaf nodes- Specified by:
getFirstChildin interfaceNode- Overrides:
getFirstChildin classAbstractNode- Returns:
- null
-
getLastChild
Get last child - default implementation used for leaf nodes- Specified by:
getLastChildin interfaceNode- Overrides:
getLastChildin classAbstractNode- Returns:
- null
-
getEnumeration
Return an enumeration over the nodes reached by the given axis from this node- Specified by:
getEnumerationin interfaceNodeInfo- Specified by:
getEnumerationin classAbstractNode- Parameters:
axisNumber- The axis to be used (a constant in classAxis)nodeTest- A pattern to be matched by the returned nodesnode- NodeInfo representing the node from which the enumeration startsnodeType- the type(s) of node to be included, e.g. NodeInfo.ELEMENT, NodeInfo.TEXT. The value NodeInfo.NODE means include any type of node.- Returns:
- an AxisEnumeration that scans the nodes reached by the axis in turn.
-
hasAttributes
public boolean hasAttributes()Returns whether this node (if it is an element) has any attributes.- Specified by:
hasAttributesin interfaceNode- Specified by:
hasAttributesin classAbstractNode- Returns:
trueif this node has any attributes,falseotherwise.- Since:
- DOM Level 2
-
getAttributeValue
Find the value of a given attribute of this node.
This method is defined on all nodes to meet XSL requirements, but for nodes other than elements it will always return null.- Specified by:
getAttributeValuein interfaceNodeInfo- Specified by:
getAttributeValuein classAbstractNode- Parameters:
uri- the namespace uri of an attributelocalName- the local name of an attribute- Returns:
- the value of the attribute, if it exists, otherwise null
-
getAttributeValue
Get the value of a given attribute of this node- Specified by:
getAttributeValuein interfaceNodeInfo- Specified by:
getAttributeValuein classAbstractNode- Parameters:
fingerprint- The fingerprint of the attribute name- Returns:
- the attribute value if it exists or null if not
-
getDocumentElement
Get the outermost element.- Overrides:
getDocumentElementin classAbstractNode- Returns:
- the Element node for the outermost element of the document. If the document is not well-formed, this returns the last element child of the root if there is one, otherwise null.
-
getDocumentRoot
Get the root (document) node- Specified by:
getDocumentRootin interfaceNodeInfo- Overrides:
getDocumentRootin classAbstractNode- Returns:
- the DocumentInfo representing the containing document
-
getNextInDocument
-
getPreviousInDocument
Get the previous node in document order- Returns:
- the previous node in the document, or null if there is no such node
-
outputNamespaceNodes
public void outputNamespaceNodes(Outputter out, boolean includeAncestors) throws TransformerException Output all namespace nodes associated with this element. Does nothing if the node is not an element.- Specified by:
outputNamespaceNodesin interfaceNodeInfo- Overrides:
outputNamespaceNodesin classAbstractNode- Parameters:
out- The relevant outputterincludeAncestors- True if namespaces declared on ancestor elements must be output; false if it is known that these are already on the result tree- Throws:
TransformerException
-
removeNode
public void removeNode()Remove this node from the tree. For system use only. When one or more nodes have been removed, renumberChildren() must be called to adjust the numbering of remaining nodes. PRECONDITION: The node must have a parent node. -
getChildNodes
Return aNodeListthat contains all children of this node. If there are no children, this is aNodeListcontaining no nodes.- Specified by:
getChildNodesin interfaceNode- Overrides:
getChildNodesin classAbstractNode
-
getAttributes
Return aNamedNodeMapcontaining the attributes of this node (if it is anElement) ornullotherwise. (DOM method)- Specified by:
getAttributesin interfaceNode- Overrides:
getAttributesin classAbstractNode
-
hasChildNodes
public boolean hasChildNodes()Determine whether the node has any children.- Specified by:
hasChildNodesin interfaceNode- Specified by:
hasChildNodesin interfaceNodeInfo- Specified by:
hasChildNodesin classAbstractNode- Returns:
trueif the node has any children,falseif the node has no children.
-