Sophie

Sophie

distrib > Mageia > 7 > i586 > by-pkgid > b3bdfe6d859a3d6920ff2c44b38e9a6f > files > 3062

saxon-manual-9.4.0.9-2.mga7.noarch.rpm

<?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="jaxp-xpath" subpage="context-node"/>
      <!--
           Generated at 2011-12-09T20:47:22.916Z--><title>Saxonica: XSLT and XQuery Processing: Setting the context item</title>
      <meta name="coverage" content="Worldwide"/>
      <meta name="copyright" content="Copyright Saxonica Ltd"/>
      <meta name="title"
            content="Saxonica: XSLT and XQuery Processing: Setting the context item"/>
      <meta name="robots" content="noindex,nofollow"/>
      <link rel="stylesheet" href="../../saxondocs.css" type="text/css"/>
   </head>
   <body class="main">
      <h1>Setting the context item</h1>
      <p>Many of the methods in the JAXP interface take an argument to represent the context node. Because the API
is designed to be used with multiple object models, this is typed simply as an <code>Object</code>. In the case of
Saxon, this can be an object in any of the supported data models: DOM, JDOM, DOM4J, XOM, or Saxon's native
<a class="bodylink" href="../../javadoc/net/sf/saxon/om/NodeInfo.html"><code>NodeInfo</code></a> representation. 
                  Note that if a <code>NodeInfo</code> is supplied, the tree must have been 
constructed using the same Saxon <a class="bodylink" href="../../javadoc/net/sf/saxon/config/Configuration.html"><code>Configuration</code></a> 
                  as the one used by the <a class="bodylink" href="../../javadoc/net/sf/saxon/xpath/XPathEvaluator.html"><code>XPathEvaluator</code></a> itself.</p>
      <p>Many of these methods specify that if the context node supplied is null, the XPath expression will be evaluated using
an empty document node as the context node. Saxon does not implement this rule. There are two reasons for this. Firstly,
it's unnatural in XPath 2.0, where it is permissible for the context item for an expression to be undefined. Secondly,
it's not clear what kind of document node it would be appropriate to create, given that Saxon supports multiple object
models. Instead, if null is supplied, then the node supplied to the Saxon-specific method <code>setContextNode()</code>
is used, and if that is null, the expression is evaluated with the context item undefined (which will cause a dynamic
error if the expression actually refers to the context item).</p>
      <table width="100%">
         <tr>
            <td>
               <p align="right"><a class="nav" href="return-types.xml">Next</a></p>
            </td>
         </tr>
      </table>
   </body>
</html>