The NodeInfo interface
The NodeInfo
object represents a node of an XML document.
It has a subclass DocumentInfo
to
represent the root node, but all other nodes are represented by NodeInfo
itself. These follow the
XPath data model closely.
In earlier releases, NodeInfo
extended the DOM interface Node
. This is no longer the case;
it was changed to make it easier to integrate Saxon with other XML tree representations such as JDOM.
Instead, a new class NodeOverNodeInfo
was introduced, which presents a (read-only) DOM view of a Saxon node.
The NodeInfo
object provides the application with
information about the node. The most commonly used methods include:
getNodeKind() |
Gets a |
getDisplayName(), getLocalPart(), getPrefix(), getURI() |
These methods get the name of the element, or its various parts. The |
getAttributeValue() |
Gets the value of a specified attribute, as a |
getStringValue() |
Gets the string value of a node, as defined in the XPath data model. |
getTypedValue() |
Gets the typed value of a node, as defined in the XPath 2.0 data model. This is in general a sequence
of atomic values, so the result is a |
getParent() |
Gets the |
iterateAxis() |
Returns an |
For other methods, see the NodeInfo
JavaDoc documentation.
It is possible (though not easy) to provide your own implementation of the NodeInfo
interface,
perhaps allowing Saxon queries to run directly against some non-XML data source. There are helper methods in the
net.sf.saxon.tree.util.Navigator
class that reduce the
amount of code you need to write to achieve this.
See the implementations that map NodeInfo
to
DOM, DOM4J, JDOM or XOM to see how it is done.