A node in the XML parse tree representing an XML element, character content, or attribute.
This is the top class in the interface hierarchy for nodes; see NodeImpl for the implementation
hierarchy.
ATTRIBUTE
public static final short ATTRIBUTE
- 2
COMMENT
public static final short COMMENT
- 8
ELEMENT
public static final short ELEMENT
- 1
NAMESPACE
public static final short NAMESPACE
- 13
NODE
public static final short NODE
- 0
NONE
public static final short NONE
- 9999
NUMBER_OF_TYPES
public static final short NUMBER_OF_TYPES
- 13
PI
public static final short PI
- 7
ROOT
public static final short ROOT
- 9
TEXT
public static final short TEXT
- 3
compareOrder
public 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.
other
- The other node, whose position is to be compared with this node
- -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())
copy
public void copy(Outputter out)
throws TransformerException
Copy this node to a given outputter
copyStringValue
public void copyStringValue(Outputter out)
throws TransformerException
Copy the string-value of this node to a given outputter
generateId
public String generateId()
Get a character string that uniquely identifies this node.
Note: a.isSameNode(b) if and only if generateId(a)==generateId(b)
- a string that uniquely identifies this node, within this
document. The calling code prepends information to make the result
unique across all documents.
getAttributeValue
public String getAttributeValue(String uri,
String localName)
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.
uri
- the namespace uri of an attribute ("" if no namespace)
- the value of the attribute, if it exists, otherwise null
getAttributeValue
public String getAttributeValue(int fingerprint)
Get the value of a given attribute of this node
fingerprint
- The fingerprint of the attribute name
- the attribute value if it exists or null if not
getBaseURI
public String getBaseURI()
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.
getDisplayName
public 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.
- The display name of this node.
For a node with no name, return an empty string.
getDocumentRoot
public DocumentInfo getDocumentRoot()
Get the root (document) node
- the DocumentInfo representing the containing document
getEnumeration
public AxisEnumeration getEnumeration(byte axisNumber,
NodeTest nodeTest)
Return an enumeration over the nodes reached by the given axis from this node
nodeTest
- A pattern to be matched by the returned nodes
- a NodeEnumeration that scans the nodes reached by the axis in turn.
getFingerprint
public int getFingerprint()
Get fingerprint. The fingerprint is a coded form of the expanded name
of the node: two nodes
with the same name code have the same namespace URI and the same local name.
A fingerprint of -1 should be returned for a node with no name.
getLineNumber
public int getLineNumber()
Get line number
- the line number of the node in its original source document; or -1 if not available
getLocalName
public String getLocalName()
Get the local part of the name of this node. This is the name after the ":" if any.
- the local part of the name. For an unnamed node, return an empty string.
getNameCode
public int getNameCode()
Get name code. The name code is a coded form of the node name: two nodes
with the same name code have the same namespace URI, the same local name,
and the same prefix. By masking the name code with &0xfffff, you get a
fingerprint: two nodes with the same fingerprint have the same local name
and namespace URI.
allocate
, getFingerprint
getNodeType
public short getNodeType()
Return the type of node.
- one of the values Node.ELEMENT, Node.TEXT, Node.ATTRIBUTE, etc.
getParent
public NodeInfo getParent()
Get the NodeInfo object representing the parent of this node
getPrefix
public String getPrefix()
Get the prefix part of the name of this node. This is the name before the ":" if any.
- the prefix part of the name. For an unnamed node, return an empty string.
getStringValue
public String getStringValue()
Return the string value of the node. The interpretation of this depends on the type
of node. For an element it is the accumulated character content of the element,
including descendant elements.
- the string value of the node
getSystemId
public String getSystemId()
Get the System ID for the node.
- 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.
getURI
public 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.
- The URI of the namespace of this node. For an unnamed node, return null.
For a node with an empty prefix, return an empty string.
hasChildNodes
public boolean hasChildNodes()
Determine whether the node has any children.
Note: the result is equivalent to
getEnumeration(Axis.CHILD, AnyNodeTest.getInstance()).hasMoreElements()
isSameNode
public boolean isSameNode(NodeInfo other)
Determine whether this is the same node as another node.
Note: a.isSameNode(b) if and only if generateId(a)==generateId(b)
- true if this Node object and the supplied Node object represent the
same node in the tree.
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.
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