<?xml version="1.0" encoding="iso-8859-1"?>
<?xml-stylesheet href="../../make-menu.xsl" type="text/xsl"?><html>
   <head>
      <this-is section="extensions" page="functions" subpage="evaluate-node"/>
      <!--
           Generated at 2011-12-09T20:47:22.916Z--><title>Saxonica: XSLT and XQuery Processing: saxon:evaluate-node()</title>
      <meta name="coverage" content="Worldwide"/>
      <meta name="copyright" content="Copyright Saxonica Ltd"/>
      <meta name="title"
            content="Saxonica: XSLT and XQuery Processing: saxon:evaluate-node()"/>
      <meta name="robots" content="noindex,nofollow"/>
      <link rel="stylesheet" href="../../saxondocs.css" type="text/css"/>
   </head>
   <body class="main">
      <h1>saxon:evaluate-node()</h1>
      <p><b>saxon:evaluate-node($node as node()) ==&gt; item()*</b></p>
      <p>This function allows XPath expressions to be read from a source document and evaluated at run-time.</p>
      <div class="boxed"
           style="border: solid thin; background-color: #B1CCC7; padding: 2px">Note that an <code>xsl:evaluate</code> instruction with similar functionality is available
                        as a standard feature in XSLT 3.0.</div>
      <p>The supplied argument must be a node, and the string-value of the node must contain an XPath expression. 
The result of the function is the result of
evaluating this XPath expression. This is useful where XPath expressions are held in source documents,
for example to parameterize the calculations performed by a query or stylesheet, or to provide XPointer-like
cross-references within a document.</p>
      <p>The static context for the expression takes the in-scope namespaces and the base URI from the node
containing the expression (or from its parent element, if it is an attribute or text node). The default namespace
defined using <code>xmlns="xyz.uri"</code> is used as the default namespace for elements and types, so that
unprefixed names in path expressions (for example <code>//data/value</code>) refer to unprefixed elements
in the containing document.</p>
      <p>The expression cannot refer to any variables defined outside the expression
itself, and it cannot refer to user-defined types or user-defined functions. However, it has access to the
standard function library (in the default function namespace) and to Saxon extension functions and Java methods.</p>
      <p>In the dynamic evaluation context, the context item is the node supplied as the first argument, while the
context position and size are both set to one. This means that the expression can be a relative path
expression referring to nodes reachable from the node that contains the expression. (Note that if this node
 is an attribute, the context node is the attribute node itself, not the containing element.)</p>
      <p>For example, given the following source document:</p>
      <div class="codeblock"
           style="border: solid thin; background-color: #B1CCC7; padding: 2px">
         <pre>
            <code>&lt;doc xmlns:alpha="http://www.alpha.com/"&gt;
  &lt;data&gt;23&lt;/data&gt;
  &lt;exp&gt;preceding-sibling::alpha:data + 5&lt;/exp&gt;
&lt;/doc&gt;</code>
         </pre>
      </div>
      <p>the expression <code>saxon:evaluate-node(//alpha:exp)</code> returns <code>28</code>.</p>
      <p>See also <a class="bodylink" href="../../extensions/functions/evaluate.xml">saxon:evaluate</a>,
which is a similar function intended for evaluating XPath expressions constructed dynamically by code
in a stylesheet or query.</p>
      <table width="100%">
         <tr>
            <td>
               <p align="right"><a class="nav" href="expression.xml">Next</a></p>
            </td>
         </tr>
      </table>
   </body>
</html>