com.icl.saxon.tinytree

Class TinyNodeImpl

abstract class TinyNodeImpl 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.

Author: Michael H. Kay

Field Summary
protected TinyDocumentImpldocument
protected intnodeNr
protected TinyNodeImplparent
Method Summary
intcompareOrder(NodeInfo other)
Determine the relative position of this node and another node, in document order.
StringgenerateId()
Get a character string that uniquely identifies this node
StringgetAttributeValue(String uri, String localName)
Find the value of a given attribute of this node.
StringgetAttributeValue(int fingerprint)
Get the value of a given attribute of this node
StringgetBaseURI()
Get the base URI for the node.
StringgetDisplayName()
Get the display name of this node.
DocumentInfogetDocumentRoot()
Get the root (document) node
AxisEnumerationgetEnumeration(byte axisNumber, NodeTest nodeTest)
Return an enumeration over the nodes reached by the given axis from this node
intgetFingerprint()
Get the fingerprint of the node, used for matching names
intgetLineNumber()
Get the line number of the node within its source document entity
StringgetLocalName()
Get the local name of this node.
intgetNameCode()
Get the name code of the node, used for matching names
NodegetOriginatingNode()
Get the node corresponding to this javax.xml.transform.dom.DOMLocator
NodeInfogetParent()
Find the parent node of this node.
StringgetPrefix()
Get the prefix part of the name of this node.
protected longgetSequenceNumber()
Get the node sequence number (in document order).
StringgetSystemId()
Get the system ID for the entity containing the node.
StringgetURI()
Get the URI part of the name of this node.
booleanhasAttributes()
Returns whether this node has any attributes.
booleanhasChildNodes()
Determine whether the node has any children.
booleanisSameNodeInfo(NodeInfo other)
Determine whether this is the same node as another node
voidoutputNamespaceNodes(Outputter out, boolean includeAncestors)
Output all namespace nodes associated with this element.
voidsetLineNumber(int line)
Set the line number of the node within its source document entity
protected voidsetParentNode(TinyNodeImpl parent)
Set the parent of this node.
voidsetSystemId(String uri)
Set the system id of this node.

Field Detail

document

protected TinyDocumentImpl document

nodeNr

protected int nodeNr

parent

protected TinyNodeImpl parent

Method Detail

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.

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())

generateId

public String generateId()
Get a character string that uniquely identifies this node

Returns: a string.

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.

Parameters: uri the namespace uri of an attribute localName the local name of an attribute

Returns: 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

Parameters: fingerprint The fingerprint of the attribute name

Returns: the attribute value if it exists or null if not

getBaseURI

public String getBaseURI()
Get the base URI for the node. Default implementation for child nodes gets the base URI of the parent node.

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.

Returns: 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

Returns: 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

Parameters: axisNumber Identifies the required axis, eg. Axis.CHILD or Axis.PARENT nodeTest A pattern to be matched by the returned nodes

Returns: a AxisEnumeration that scans the nodes reached by the axis in turn.

getFingerprint

public int getFingerprint()
Get the fingerprint of the node, used for matching names

getLineNumber

public int getLineNumber()
Get the line number of the node within its source document entity

getLocalName

public String getLocalName()
Get the local name of this node.

Returns: The local name of this node. For a node with no name, return an empty string.

getNameCode

public int getNameCode()
Get the name code of the node, used for matching names

getOriginatingNode

public Node getOriginatingNode()
Get the node corresponding to this javax.xml.transform.dom.DOMLocator

getParent

public NodeInfo getParent()
Find the parent node of this node.

Returns: The Node object describing the containing element or root node.

getPrefix

public 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 "".

getSequenceNumber

protected long getSequenceNumber()
Get the node sequence number (in document order). Sequence numbers are monotonic but not consecutive. The sequence number must be unique within the document (not, as in previous releases, within the whole document collection)

getSystemId

public String getSystemId()
Get the system ID for the entity containing the node.

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.

Returns: The URI of the namespace of this node. For an unnamed node, or for an element or attribute in the default namespace, return an empty string.

hasAttributes

public boolean hasAttributes()
Returns whether this node has any attributes.

Returns: true if this node has any attributes, false otherwise.

Since: DOM Level 2

hasChildNodes

public boolean hasChildNodes()
Determine whether the node has any children.

Returns: true if this node has any attributes, false otherwise.

isSameNodeInfo

public boolean isSameNodeInfo(NodeInfo other)
Determine whether this is the same node as another node

Returns: 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)
Output all namespace nodes associated with this element. Does nothing if the node is not an element.

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

setLineNumber

public void setLineNumber(int line)
Set the line number of the node within its source document entity

setParentNode

protected void setParentNode(TinyNodeImpl parent)
Set the parent of this node. Providing this information is useful, if it is known, because otherwise getParent() has to search backwards through the document.

setSystemId

public void setSystemId(String uri)
Set the system id of this node.
This method is present to ensure that the class implements the javax.xml.transform.Source interface, so a node can be used as the source of a transformation.