## net.sf.saxon.tree
Class NodeImpl

    java.lang.Object
      |
      +--net.sf.saxon.om.AbstractNode
            |
            +--net.sf.saxon.tree.NodeImpl

All Implemented Interfaces:
  javax.xml.transform.dom.DOMLocator, FingerprintedNode, Item, org.w3c.dom.Node, NodeInfo, javax.xml.transform.Source, javax.xml.transform.SourceLocator

Direct Known Subclasses:
  net.sf.saxon.tree.ParentNodeImpl

public abstract class NodeImpl
extends AbstractNode

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.

Field Summary
`protected int` `index`
`protected net.sf.saxon.tree.ParentNodeImpl` `parent`

Fields inherited from class net.sf.saxon.om.AbstractNode
`NODE_LETTER`

Fields inherited from interface org.w3c.dom.Node
`ATTRIBUTE_NODE, CDATA_SECTION_NODE, COMMENT_NODE, DOCUMENT_FRAGMENT_NODE, DOCUMENT_NODE, DOCUMENT_TYPE_NODE, ELEMENT_NODE, ENTITY_NODE, ENTITY_REFERENCE_NODE, NOTATION_NODE, PROCESSING_INSTRUCTION_NODE, TEXT_NODE`

Fields inherited from interface net.sf.saxon.om.NodeInfo
`ALL_NAMESPACES, LOCAL_NAMESPACES, NO_NAMESPACES`

Constructor Summary
`NodeImpl()`

Method Summary
`int` `compareOrder(NodeInfo other)` Determine the relative position of this node and another node, in document order.
`abstract void` `copy(Receiver out, int whichNamespaces)`
`void` `copy(Receiver out, int whichNamespaces, boolean copyAnnotations, int locationId)` Copy nodes.
`java.lang.String` `generateId()` Get a character string that uniquely identifies this node within this document (The calling code will prepend a document identifier)
`java.lang.String` `getAttributeValue(int fingerprint)` Get the value of a given attribute of this node
`java.lang.String` `getBaseURI()` Get the base URI for the node.
`java.lang.String` `getDisplayName()` Get the display name of this node.
`org.w3c.dom.Element` `getDocumentElement()` Get the outermost element.
`DocumentInfo` `getDocumentRoot()` Get the root (document) node
`int` `getFingerprint()` Get the fingerprint of the node.
`org.w3c.dom.Node` `getFirstChild()` Get first child - default implementation used for leaf nodes
`org.w3c.dom.Node` `getLastChild()` Get last child - default implementation used for leaf nodes
`int` `getLineNumber()` Get the line number of the node within its source document entity
`java.lang.String` `getLocalPart()` Get the local name of this node.
`int` `getNameCode()` Get the nameCode of the node.
`NamePool` `getNamePool()` Get the NamePool
`NodeImpl` `getNextInDocument(NodeImpl anchor)` Get the next node in document order
`org.w3c.dom.Node` `getNextSibling()` Get next sibling node
`org.w3c.dom.Node` `getOriginatingNode()` Get the node corresponding to this javax.xml.transform.dom.DOMLocator
`NodeInfo` `getParent()` Find the parent node of this node.
`java.lang.String` `getPrefix()` Get the prefix part of the name of this node.
`NodeImpl` `getPreviousInDocument()` Get the previous node in document order
`org.w3c.dom.Node` `getPreviousSibling()` Get the previous sibling of the node
`NodeInfo` `getRoot()` Get the root node
`protected long` `getSequenceNumber()` Get the node sequence number (in document order).
`java.lang.String` `getSystemId()` Get the system ID for the node.
`java.lang.String` `getURI()` Get the URI part of the name of this node.
`boolean` `hasAttributes()` Returns whether this node (if it is an element) has any attributes.
`boolean` `hasChildNodes()` Determine whether the node has any children.
`boolean` `isSameNodeInfo(NodeInfo other)` Determine whether this is the same node as another node
`AxisIterator` `iterateAxis(byte axisNumber)` Return an enumeration over the nodes reached by the given axis from this node
`AxisIterator` `iterateAxis(byte axisNumber, NodeTest nodeTest)` Return an enumeration over the nodes reached by the given axis from this node
`void` `outputNamespaceNodes(Receiver out, boolean includeAncestors)` Output all namespace nodes associated with this element.
`void` `setSystemId(java.lang.String uri)` Set the system ID of this node.

Methods inherited from class net.sf.saxon.om.AbstractNode

`appendChild, appendData, cloneNode, compareDocumentPosition, createAttribute, createAttributeNS, createCDATASection, createComment, createDocumentFragment, createElement, createElementNS, createEntityReference, createProcessingInstruction, createTextNode, deleteData, disallowUpdate, getAttribute, getAttributeNode, getAttributeNodeNS, getAttributeNS, getAttributes, getChildNodes, getColumnNumber, getData, getDoctype, getDocumentNumber, getElementById, getElementsByTagName, getElementsByTagNameNS, getFeature, getImplementation, getLength, getLocalName, getName, getNamespaceURI, getNodeName, getNodeType, getNodeValue, getOwnerDocument, getOwnerElement, getParentNode, getPublicId, getSchemaTypeInfo, getSpecified, getStringValue, getTagName, getTextContent, getTypeAnnotation, getTypedValue, getUserData, getValue, hasAttribute, hasAttributeNS, importNode, insertBefore, insertData, isDefaultNamespace, isEqualNode, isId, isSameNode, isSupported, lookupNamespaceURI, lookupPrefix, normalize, removeAttribute, removeAttributeNode, removeAttributeNS, removeChild, replaceChild, replaceData, setAttributeNode, setAttributeNodeNS, setAttributeNS, setData, setIdAttribute, setIdAttributeNode, setIdAttributeNS, setNodeValue, setPrefix, setTextContent, setValue, splitText, substringData, supports`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Methods inherited from interface net.sf.saxon.om.NodeInfo
`getNodeKind`

Field Detail

### parent

    protected net.sf.saxon.tree.ParentNodeImpl parent

### index

    protected int index

Constructor Detail

### NodeImpl

    public NodeImpl()

Method Detail

### setSystemId

    public void setSystemId(java.lang.String uri)

  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

    public boolean isSameNodeInfo(NodeInfo other)

  Determine whether this is the same node as another node

  Specified by:
    `isSameNodeInfo` in interface `NodeInfo`
  Specified by:
    `isSameNodeInfo` in class `AbstractNode`
  Parameters:
    `other` - the node to be compared with this node
  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:
    `getNameCode` in interface `NodeInfo`
  Specified by:
    `getNameCode` in class `AbstractNode`
  Returns:
    an integer name code, which may be used to obtain the actual node name from the name pool
  See Also:
    `allocate`, `getFingerprint`

### 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:
    `getFingerprint` in interface `NodeInfo`
  Specified by:
    `getFingerprint` in class `AbstractNode`
  Returns:
    an integer fingerprint; two nodes with the same fingerprint have the same expanded QName

### generateId

    public java.lang.String generateId()

  Get a character string that uniquely identifies this node within this document (The calling code will prepend a document identifier)

  Specified by:
    `generateId` in interface `NodeInfo`
  Specified by:
    `generateId` in class `AbstractNode`
  Returns:
    a string.

### getOriginatingNode

    public org.w3c.dom.Node getOriginatingNode()

  Get the node corresponding to this javax.xml.transform.dom.DOMLocator

  Specified by:
    `getOriginatingNode` in interface `javax.xml.transform.dom.DOMLocator`
  Overrides:
    `getOriginatingNode` in class `AbstractNode`

### getSystemId

    public java.lang.String getSystemId()

  Get the system ID for the node. Default implementation for child nodes.

  Specified by:
    `getSystemId` in interface `NodeInfo`
  Specified by:
    `getSystemId` in class `AbstractNode`
  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

    public java.lang.String getBaseURI()

  Get the base URI for the node. Default implementation for child nodes.

  Specified by:
    `getBaseURI` in interface `NodeInfo`
  Specified by:
    `getBaseURI` in class `AbstractNode`
  Returns:
    the base URI of the node

### 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

    public final int compareOrder(NodeInfo other)

  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:
    `compareOrder` in interface `NodeInfo`
  Specified by:
    `compareOrder` in class `AbstractNode`
  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

    public NamePool getNamePool()

  Get the NamePool

  Returns:
    the namepool

### getPrefix

    public java.lang.String getPrefix()

  Get the prefix part of the name of this node. This is the name before the ":" if any.

  Returns:
    the prefix part of the name. For an unnamed node, return an empty string.

### getURI

    public java.lang.String 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:
    `getURI` in interface `NodeInfo`
  Specified by:
    `getURI` in class `AbstractNode`
  Returns:
    The URI of the namespace of this node. For the default namespace, return an empty string. For an unnamed node, return the empty string.

### getDisplayName

    public java.lang.String 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:
    `getDisplayName` in interface `NodeInfo`
  Overrides:
    `getDisplayName` in class `AbstractNode`
  Returns:
    The display name of this node. For a node with no name, return an empty string.

### getLocalPart

    public java.lang.String getLocalPart()

  Get the local name of this node.

  Specified by:
    `getLocalPart` in interface `NodeInfo`
  Specified by:
    `getLocalPart` in class `AbstractNode`
  Returns:
    The local name of this node. For a node with no name, return "",.

### getLineNumber

    public int getLineNumber()

  Get the line number of the node within its source document entity

  Specified by:
    `getLineNumber` in interface `NodeInfo`
  Overrides:
    `getLineNumber` in class `AbstractNode`
  Returns:
    the line number of the node in its original source document; or -1 if not available

### getParent

    public final NodeInfo getParent()

  Find the parent node of this node.

  Specified by:
    `getParent` in interface `NodeInfo`
  Specified by:
    `getParent` in class `AbstractNode`
  Returns:
    The Node object describing the containing element or root node.

### getPreviousSibling

    public org.w3c.dom.Node getPreviousSibling()

  Get the previous sibling of the node

  Specified by:
    `getPreviousSibling` in interface `org.w3c.dom.Node`
  Overrides:
    `getPreviousSibling` in class `AbstractNode`
  Returns:
    The previous sibling node. Returns null if the current node is the first child of its parent.

### getNextSibling

    public org.w3c.dom.Node getNextSibling()

  Get next sibling node

  Specified by:
    `getNextSibling` in interface `org.w3c.dom.Node`
  Overrides:
    `getNextSibling` in class `AbstractNode`
  Returns:
    The next sibling node of the required type. Returns null if the current node is the last child of its parent.

### getFirstChild

    public org.w3c.dom.Node getFirstChild()

  Get first child - default implementation used for leaf nodes

  Specified by:
    `getFirstChild` in interface `org.w3c.dom.Node`
  Overrides:
    `getFirstChild` in class `AbstractNode`
  Returns:
    null

### getLastChild

    public org.w3c.dom.Node getLastChild()

  Get last child - default implementation used for leaf nodes

  Specified by:
    `getLastChild` in interface `org.w3c.dom.Node`
  Overrides:
    `getLastChild` in class `AbstractNode`
  Returns:
    null

### iterateAxis

    public AxisIterator iterateAxis(byte axisNumber)

  Return an enumeration over the nodes reached by the given axis from this node

  Parameters:
    `axisNumber` - The axis to be iterated over
  Returns:
    an AxisIterator that scans the nodes reached by the axis in turn.
  See Also:
    `Axis`

### iterateAxis

    public AxisIterator iterateAxis(byte axisNumber,
                                    NodeTest nodeTest)

  Return an enumeration over the nodes reached by the given axis from this node

  Specified by:
    `iterateAxis` in interface `NodeInfo`
  Specified by:
    `iterateAxis` in class `AbstractNode`
  Parameters:
    `axisNumber` - The axis to be iterated over
    `nodeTest` - A pattern to be matched by the returned nodes
  Returns:
    an AxisIterator 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:
    `hasAttributes` in interface `org.w3c.dom.Node`
  Specified by:
    `hasAttributes` in class `AbstractNode`
  Returns:
    `true` if this node has any attributes, `false` otherwise.
  Since:
    DOM Level 2

### getAttributeValue

    public java.lang.String getAttributeValue(int fingerprint)

  Get the value of a given attribute of this node

  Specified by:
    `getAttributeValue` in interface `NodeInfo`
  Specified by:
    `getAttributeValue` in class `AbstractNode`
  Parameters:
    `fingerprint` - The fingerprint of the attribute name
  Returns:
    the attribute value if it exists or null if not

### getDocumentElement

    public org.w3c.dom.Element getDocumentElement()

  Get the outermost element.

  Overrides:
    `getDocumentElement` in class `AbstractNode`
  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.

### getRoot

    public NodeInfo getRoot()

  Get the root node

  Specified by:
    `getRoot` in interface `NodeInfo`
  Overrides:
    `getRoot` in class `AbstractNode`
  Returns:
    the NodeInfo representing the containing document

### getDocumentRoot

    public DocumentInfo getDocumentRoot()

  Get the root (document) node

  Specified by:
    `getDocumentRoot` in interface `NodeInfo`
  Overrides:
    `getDocumentRoot` in class `AbstractNode`
  Returns:
    the DocumentInfo representing the containing document

### getNextInDocument

    public NodeImpl getNextInDocument(NodeImpl anchor)

  Get the next node in document order

  Returns:
    the next node in the document, or null if there is no such node

### getPreviousInDocument

    public NodeImpl 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(Receiver out,
                                     boolean includeAncestors)
                              throws XPathException

  Output all namespace nodes associated with this element. Does nothing if the node is not an element.

  Specified by:
    `outputNamespaceNodes` in interface `NodeInfo`
  Overrides:
    `outputNamespaceNodes` in class `AbstractNode`
  Parameters:
    `out` - The relevant outputter
    `includeAncestors` - True if namespaces declared on ancestor elements must be output; false if it is known that these are already on the result tree
    `XPathException`

### copy

    public final void copy(Receiver out,
                           int whichNamespaces,
                           boolean copyAnnotations,
                           int locationId)
                    throws XPathException

  Copy nodes. Copying type annotations is not yet supported for this tree structure, so we simply map the new interface onto the old

  Parameters:
    `out` - the Receiver to which the node should be copied
    `whichNamespaces` - in the case of an element, controls which namespace nodes should be copied. Values are NO_NAMESPACES, LOCAL_NAMESPACES, ALL_NAMESPACES
    `copyAnnotations` - indicates whether the type annotations of element and attribute nodes should be copied
    `locationId` - Identifies the location of the instruction that requested this copy. Pass zero if no other information is available
  Throws:
    `XPathException`

### copy

    public abstract void copy(Receiver out,
                              int whichNamespaces)
                       throws XPathException

    `XPathException`

### hasChildNodes

    public boolean hasChildNodes()

  Determine whether the node has any children.

  Specified by:
    `hasChildNodes` in interface `org.w3c.dom.Node`
  Specified by:
    `hasChildNodes` in class `AbstractNode`
  Returns:
    `true` if the node has any children, `false` if the node has no children.