com.icl.saxon.om
Interface NodeInfo

All Superinterfaces:
org.w3c.dom.Node
All Known Subinterfaces:
AttributeInfo, CommentInfo, DocumentInfo, ElementInfo, NamespaceInfo, ProcInstInfo, TextInfo
All Known Implementing Classes:
com.icl.saxon.tree.NodeImpl

public interface NodeInfo
extends org.w3c.dom.Node

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.


Field Summary
static short ATTRIBUTE
           
static short COMMENT
           
static short DOCUMENT
           
static short ELEMENT
           
static short NAMESPACE
           
static short NODE
           
static short NONE
           
static short NUMBER_OF_TYPES
           
static short PI
           
static short TEXT
           
 
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
 
Method Summary
 void copy(Outputter out)
          Copy this node to a given outputter
 void copyStringValue(Outputter out)
          Copy the string-value of this node to a given outputter
 void defaultAction(Context c)
          Perform default action for this kind of node (built-in template rule)
 java.lang.String getAbsoluteName()
          Get the absolute name of this node.
 NodeInfo[] getAllChildNodes()
          Get all child nodes of the element (child elements and character nodes)
 ElementInfo getAncestor(Name name)
          Get the nearest ancestor element with a given element name
 NodeInfo getAncestor(Pattern pat, Context context)
          Get the nearest ancestor node that matches the given pattern
 java.lang.String getAttributeValue(Name name)
          Find the value of a given attribute of this node.
 java.lang.String getAttributeValue(java.lang.String name)
          Find the value of a given attribute of this 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
 Name getExpandedName()
          Get the expanded name of this node, following the XPath naming rules
 NodeInfo getFirstChild(Pattern pattern, Context context)
          Get the first child node of a given type.
 int getIndex()
          Get index: that is, the number of preceding sibling nodes at the same level.
 NodeInfo getLastChild(Pattern pattern, Context context)
          Get the last child node of a given type
 int getLineNumber()
          Get line number
 java.lang.String getLocalName()
          Get the local part of the name of this node.
 NodeInfo getNextInDocument(NodeInfo anchor)
          Get the next node in document order
 NodeInfo getNextSibling(Pattern pattern, Context context)
          Get the next sibling node that matches a given pattern.
 java.lang.String getNodeName()
          Get the name of this node, following the DOM rules
 short getNodeType()
          Return the type of node.
 int getNumberAny(Pattern count, Pattern from, Context c)
          Get node number (level="any").
 java.util.Vector getNumberMulti(Pattern count, Pattern from, Context c)
          Get node number (level="multi").
 int getNumberOfChildren()
          Get the number of children.
 int getNumberSimple()
          Get simple node number.
 int getNumberSimple(Context context)
          Get simple node number.
 int getNumberSingle(Pattern count, Pattern from, Context c)
          Get node number (level="single").
 java.lang.String getPath()
          Generate a path to this node
 java.lang.String getPrefix()
          Get the prefix part of the name of this node.
 NodeInfo getPreviousInDocument()
          Get the previous node in document order
 NodeInfo getPreviousInDocument(Pattern pattern, Context context)
          Get the previous node in document order
 NodeInfo getPreviousSibling(Pattern pattern, Context context)
          Get the previous sibling of the node that matches a given pattern.
 long getSequenceNumber()
          Get the node sequence number (in document order).
 java.lang.String getSequentialKey()
          Get a character string that uniquely identifies this node and that collates nodes into document order
 java.lang.String getSystemId()
          Get the base URL for the node.
 java.lang.String getURI()
          Get the URI part of the name of this node.
 java.lang.String getValue()
          Return the character value of the node.
 boolean hasName(Name name)
          Test if the name of the node (including namespaces) is equivalent to the given name
 boolean isa(int nodeType)
          Determine whether the node is of a given type.
 boolean isAncestor(NodeInfo other)
          Determine whether this node is an ancestor of another node
 boolean isDocumentElement()
          Determine whether this element is the outermost element.
 boolean isSameNode(NodeInfo other)
          Determine whether this is the same node as another node
 
Methods inherited from interface org.w3c.dom.Node
appendChild, cloneNode, getAttributes, getChildNodes, getFirstChild, getLastChild, getNamespaceURI, getNextSibling, getNodeValue, getOwnerDocument, getParentNode, getPreviousSibling, hasAttributes, hasChildNodes, insertBefore, isSupported, normalize, removeChild, replaceChild, setNodeValue, setPrefix
 

Field Detail

NODE

public static final short NODE

ELEMENT

public static final short ELEMENT

ATTRIBUTE

public static final short ATTRIBUTE

TEXT

public static final short TEXT

DOCUMENT

public static final short DOCUMENT

PI

public static final short PI

COMMENT

public static final short COMMENT

NAMESPACE

public static final short NAMESPACE

NUMBER_OF_TYPES

public static final short NUMBER_OF_TYPES

NONE

public static final short NONE
Method Detail

getNodeType

public short getNodeType()
Return the type of node.
Specified by:
getNodeType in interface org.w3c.dom.Node
Returns:
one of the values Node.ELEMENT, Node.TEXT, Node.ATTRIBUTE, etc.

isa

public boolean isa(int nodeType)
Determine whether the node is of a given type.

Note, this can also be done by testing the node using "instanceof". But this is inconvenient when passing the class as a parameter to another routine.

Parameters:
nodeType - One of the specific node types such as ELEMENT or TEXT, or the general node type NODE
Returns:
true if the node is an instance of the specified node type

isSameNode

public boolean isSameNode(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.

getSystemId

public java.lang.String getSystemId()
Get the base URL for the node.
Returns:
the System Identifier of the entity in the source document containing the node, or null if not known

getLineNumber

public int getLineNumber()
Get line number
Returns:
the line number of the node in its original source document; or -1 if not available

getSequenceNumber

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

getValue

public java.lang.String getValue()
Return the character 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.
Returns:
the string value of the node

getExpandedName

public Name getExpandedName()
Get the expanded name of this node, following the XPath naming rules
Returns:
The name of the node. For an element this is the element name, for an attribute it is the attribute name, complete with namespace information. Other node types return null.

getNodeName

public java.lang.String getNodeName()
Get the name of this node, following the DOM rules
Specified by:
getNodeName in interface org.w3c.dom.Node
Returns:
The name of the node. For an element this is the element name, for an attribute it is the attribute name, as a QName. Other node types return conventional names such as "#text" or "#comment"

getLocalName

public java.lang.String getLocalName()
Get the local part of the name of this node. This is the name after the ":" if any.
Specified by:
getLocalName in interface org.w3c.dom.Node
Returns:
the local part of the name. For an unnamed node, return an empty string.

getPrefix

public java.lang.String getPrefix()
Get the prefix part of the name of this node. This is the name before the ":" if any.
Specified by:
getPrefix in interface org.w3c.dom.Node
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.
Returns:
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.

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.
Returns:
The display name of this node. For a node with no name, return an empty string.

getAbsoluteName

public java.lang.String getAbsoluteName()
Get the absolute name of this node. For elements and attributes this is [uri^]localname. For other nodes, it is the same as the display name
Returns:
The absolute name of this node. For a node with no name, return an empty string.

hasName

public boolean hasName(Name name)
Test if the name of the node (including namespaces) is equivalent to the given name

getAttributeValue

public java.lang.String getAttributeValue(Name name)
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:
name - the name of an attribute
Returns:
the value of the attribute, if it exists, otherwise null

getAttributeValue

public java.lang.String getAttributeValue(java.lang.String name)
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:
name - the name of an attribute. This must be an unqualified attribute name, i.e. one with no namespace.
Returns:
the value of the attribute, if it exists, otherwise null

getAncestor

public ElementInfo getAncestor(Name name)
Get the nearest ancestor element with a given element name
Parameters:
name - The name of the required ancestor
Returns:
The NodeInfo for the nearest ancestor with the given tag; null if there is no such ancestor

getAncestor

public NodeInfo getAncestor(Pattern pat,
                            Context context)
                     throws org.xml.sax.SAXException
Get the nearest ancestor node that matches the given pattern
Parameters:
pattern - A pattern that the ancestor node must satisfy.
Returns:
The NodeInfo for the nearest ancestor node that matches the given pattern; null if there is no such ancestor

isDocumentElement

public boolean isDocumentElement()
Determine whether this element is the outermost element.
Returns:
True if this element is the outermost element.

isAncestor

public boolean isAncestor(NodeInfo other)
Determine whether this node is an ancestor of another node
Parameters:
other - the other node (the putative descendant of this node)
Returns:
true of this node is an ancestor of the other node

getDocumentElement

public org.w3c.dom.Element getDocumentElement()
Get the outermost element.
Returns:
the Element for the outermost element of the document.

getDocumentRoot

public DocumentInfo getDocumentRoot()
Get the root (document) node
Returns:
the DocumentInfo representing the containing document

getNextSibling

public NodeInfo getNextSibling(Pattern pattern,
                               Context context)
                        throws org.xml.sax.SAXException
Get the next sibling node that matches a given pattern.
Parameters:
pattern - The match-pattern that the required sibling must match
Returns:
The NodeInfo object describing the next node at the same level. Returns null if there is no subsequent child of the same parent that matches the supplied pattern.

getNextInDocument

public NodeInfo getNextInDocument(NodeInfo anchor)
Get the next node in document order
Parameters:
anchor: - the scan stops when it reaches a node that is not a descendant of the specified anchor node
Returns:
the next node in the document, or null if there is no such node

getFirstChild

public NodeInfo getFirstChild(Pattern pattern,
                              Context context)
                       throws org.xml.sax.SAXException
Get the first child node of a given type.
Parameters:
pattern: - identifies the pattern to be matched by the required child
Returns:
the the first child node of the required type, or null if there is no such child

getPreviousSibling

public NodeInfo getPreviousSibling(Pattern pattern,
                                   Context context)
                            throws org.xml.sax.SAXException
Get the previous sibling of the node that matches a given pattern.
Parameters:
pattern - The match-pattern that the required sibling must match
Returns:
The NodeInfo object describing the previous node at the same level that matches the pattern. Returns null if there is no previous child of the same parent that matches the supplied pattern.

getPreviousInDocument

public NodeInfo getPreviousInDocument()
Get the previous node in document order
Returns:
the previous node in the document, or null if there is no such node

getPreviousInDocument

public NodeInfo getPreviousInDocument(Pattern pattern,
                                      Context context)
                               throws org.xml.sax.SAXException
Get the previous node in document order
Parameters:
pattern: - identifies a pattern the required node
Returns:
the previous node in the document of the required type, or null if there is no such node

getLastChild

public NodeInfo getLastChild(Pattern pattern,
                             Context context)
                      throws org.xml.sax.SAXException
Get the last child node of a given type
Parameters:
pattern: - identifies the pattern to be matched by the required child
Returns:
the the last child node of the required type, or null if there is no such child

getNumberOfChildren

public int getNumberOfChildren()
Get the number of children.

getAllChildNodes

public NodeInfo[] getAllChildNodes()
Get all child nodes of the element (child elements and character nodes)
Returns:
an array containing a NodeInfo for each child node

getIndex

public int getIndex()
Get index: that is, the number of preceding sibling nodes at the same level. Note this is not defined for attribute nodes.
Returns:
the number of preceding sibling nodes at the same level

getNumberSimple

public int getNumberSimple(Context context)
Get simple node number. This is defined as one plus the number of previous siblings of the same node type and name. It is not accessible directly in XSL. The context is used to remember information from one call to the next, for performance benefits.

getNumberSimple

public int getNumberSimple()
                    throws org.xml.sax.SAXException
Get simple node number. This is defined as one plus the number of previous siblings of the same node type and name. It is not accessible directly in XSL.

getNumberSingle

public int getNumberSingle(Pattern count,
                           Pattern from,
                           Context c)
                    throws org.xml.sax.SAXException
Get node number (level="single"). If the current node matches the supplied pattern, the returned number is one plus the number of previous siblings that match the pattern. Otherwise, return the element number of the nearest ancestor that matches the supplied pattern.
Parameters:
count - Pattern that identifies which nodes should be counted. Default (null) is the element name if the current node is an element, or "node()" otherwise.
from - Pattern that specifies where counting starts from. Default (null) is the root node. (This parameter does not seem useful but is included for the sake of XSLT conformance.)
Returns:
the node number established as follows: go to the nearest ancestor-or-self that matches the 'count' pattern and that is a descendant of the nearest ancestor that matches the 'from' pattern. Return one plus the nunber of preceding siblings of that ancestor that match the 'count' pattern. If there is no such ancestor, return 0.

getNumberAny

public int getNumberAny(Pattern count,
                        Pattern from,
                        Context c)
                 throws org.xml.sax.SAXException
Get node number (level="any"). Return one plus the number of previous nodes in the document that match the supplied pattern
Parameters:
count - Pattern that identifies which nodes should be counted. Default (null) is the element name if the current node is an element, or "node()" otherwise.
from - Pattern that specifies where counting starts from. Default (null) is the root node. Only nodes after the first (most recent) node that matches the 'from' pattern are counted.
Returns:
one plus the number of nodes that precede the current node, that match the count pattern, and that follow the first node that matches the from pattern if specified.

getNumberMulti

public java.util.Vector getNumberMulti(Pattern count,
                                       Pattern from,
                                       Context c)
                                throws org.xml.sax.SAXException
Get node number (level="multi"). Return a vector giving the hierarchic position of this node. See the XSLT spec for details.
Parameters:
count - Pattern that identifies which nodes (ancestors and their previous siblings) should be counted. Default (null) is the element name if the current node is an element, or "node()" otherwise.
from - Pattern that specifies where counting starts from. Default (null) is the root node. Only nodes below the first (most recent) node that matches the 'from' pattern are counted.
Returns:
a vector containing for each ancestor-or-self that matches the count pattern and that is below the nearest node that matches the from pattern, an Integer which is one greater than the number of previous siblings that match the count pattern.

getSequentialKey

public java.lang.String getSequentialKey()
Get a character string that uniquely identifies this node and that collates nodes into document order
Returns:
a string. The string is always interned so keys can be compared using "==".

defaultAction

public void defaultAction(Context c)
                   throws org.xml.sax.SAXException
Perform default action for this kind of node (built-in template rule)

copy

public void copy(Outputter out)
          throws org.xml.sax.SAXException
Copy this node to a given outputter

copyStringValue

public void copyStringValue(Outputter out)
                     throws org.xml.sax.SAXException
Copy the string-value of this node to a given outputter

getPath

public java.lang.String getPath()
Generate a path to this node