<?xml version="1.0" encoding="iso-8859-1"?>
<?xml-stylesheet href="../make-menu.xsl" type="text/xsl"?><html>
   <head>
      <this-is section="xpath-api" page="nodeinfo" subpage=""/>
      <!--
           Generated at 2011-12-09T20:47:22.916Z--><title>Saxonica: XSLT and XQuery Processing: The NodeInfo interface</title>
      <meta name="coverage" content="Worldwide"/>
      <meta name="copyright" content="Copyright Saxonica Ltd"/>
      <meta name="title"
            content="Saxonica: XSLT and XQuery Processing: The NodeInfo interface"/>
      <meta name="robots" content="noindex,nofollow"/>
      <link rel="stylesheet" href="../saxondocs.css" type="text/css"/>
   </head>
   <body class="main">
      <h1>The NodeInfo interface</h1>
      <p>The <a class="bodylink" href="../javadoc/net/sf/saxon/om/NodeInfo.html"><code>NodeInfo</code></a> object represents a node of an XML document. 
               It has a subclass <a class="bodylink" href="../javadoc/net/sf/saxon/om/DocumentInfo.html"><code>DocumentInfo</code></a> to
represent the root node, but all other nodes are represented by <code>NodeInfo</code> itself. These follow the
XPath data model closely.</p>
      <p><i>In earlier releases, <a class="bodylink" href="../javadoc/net/sf/saxon/om/NodeInfo.html"><code>NodeInfo</code></a> 
                     extended the DOM interface <code>Node</code>. 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 <a class="bodylink" href="../javadoc/net/sf/saxon/dom/NodeOverNodeInfo.html"><code>NodeOverNodeInfo</code></a>
was introduced, which presents a (read-only) DOM view of a Saxon node.</i></p>
      <p>The <a class="bodylink" href="../javadoc/net/sf/saxon/om/NodeInfo.html"><code>NodeInfo</code></a> object provides the application with
information about the node. The most commonly used methods include:</p>
      <table>
         <tr>
            <td content="para">
               <p>getNodeKind()</p>
            </td>
            <td content="para">
               <p>gets a short identifying the node type (for example, element or attribute). The values are
     consistent with those used in the DOM, and are referenced by constants in the class
                     <a class="bodylink" href="../javadoc/net/sf/saxon/type/Type.html"><code>net.sf.saxon.type.Type</code></a>
            </p>
            </td>
         </tr>
         <tr>
            <td content="para">
               <p>getDisplayName(), getLocalPart(), getPrefix(), getURI()</p>
            </td>
            <td content="para">
               <p>These methods get the name of the element, or its various parts. The <code>getDisplayName()</code>
    method returns the QName as used in the original source XML.</p>
            </td>
         </tr>
         <tr>
            <td content="para">
               <p>getAttributeValue()</p>
            </td>
            <td content="para">
               <p>get the value of a specified attribute, as a String.</p>
            </td>
         </tr>
         <tr>
            <td content="para">
               <p>getStringValue()</p>
            </td>
            <td content="para">
               <p>get the string value of a node, as defined in the XPath data model</p>
            </td>
         </tr>
         <tr>
            <td content="para">
               <p>getTypedValue()</p>
            </td>
            <td content="para">
               <p>get 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 <a class="bodylink" href="../javadoc/net/sf/saxon/om/SequenceIterator.html"><code>SequenceIterator</code></a>.</p>
            </td>
         </tr>
         <tr>
            <td content="para">
               <p>getParent()</p>
            </td>
            <td content="para">
               <p>get the <a class="bodylink" href="../javadoc/net/sf/saxon/om/NodeInfo.html"><code>NodeInfo</code></a> 
                           representing the parent element, (which will be a 
                           <a class="bodylink" href="../javadoc/net/sf/saxon/om/DocumentInfo.html"><code>DocumentInfo</code></a> object
     if this is the outermost element).</p>
            </td>
         </tr>
         <tr>
            <td content="para">
               <p>iterateAxis()</p>
            </td>
            <td content="para">
               <p>returns an <a class="bodylink" href="../javadoc/net/sf/saxon/om/SequenceIterator.html"><code>SequenceIterator</code></a> 
                           object that can be used to iterate over the nodes on any of the
    XPath axes. The first argument is an integer identifying the axis; the second is a 
                           <a class="bodylink" href="../javadoc/net/sf/saxon/pattern/NodeTest.html"><code>NodeTest</code></a> (a
    simple form of pattern) which can be used to filter the nodes on the axis. Supply <code>null</code>
    if you want all the nodes on the axis. (For most applications, it is probably simpler to navigate
    from a node by compiling an XPath expression, and executing it with the correct starting node as
    the context node).</p>
            </td>
         </tr>
      </table>
      <p>For other methods, see the JavaDoc documentation.</p>
      <p>It is possible (though not easy) to provide your own implementation of the <code>NodeInfo</code> interface,
perhaps allowing Saxon queries to run directly against some non-XML data source. There are helper methods in the
               <a class="bodylink" href="../javadoc/net/sf/saxon/om/Navigator.html"><code>net.sf.saxon.om.Navigator</code></a> class that reduce the 
               amount of code you need to write to achieve this.
               See the implementations that map <a class="bodylink" href="../javadoc/net/sf/saxon/om/NodeInfo.html"><code>NodeInfo</code></a> to 
               DOM, DOM4J, JDOM or XOM to see how it is done.</p>
      <table width="100%">
         <tr>
            <td>
               <p align="right"/>
            </td>
         </tr>
      </table>
   </body>
</html>