<?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"/>
      <!--
           Generated at 2010-10-29T18:20:48.427+01:00--><title>Saxonica: XSLT and XQuery Processing: saxon:evaluate()</title>
      <meta name="coverage" content="Worldwide"/>
      <meta name="copyright" content="Copyright Saxonica Ltd"/>
      <meta name="title" content="Saxonica: XSLT and XQuery Processing: saxon:evaluate()"/>
      <meta name="robots" content="noindex,nofollow"/>
      <link rel="stylesheet" href="../../saxondocs.css" type="text/css"/>
   </head>
   <body class="main">
      <h1>saxon:evaluate()</h1>
      <p><b>saxon:evaluate($in as xs:string [, $paramN as item()* ...]) ==&gt; item()*</b></p>
      <p>This function allows XPath expressions to be constructed and evaluated dynamically at runtime.</p>
      <p>The supplied string must contain an XPath expression. The result of the function is the result of
evaluating the XPath expression. This is useful where an expression needs to be constructed
at run-time or passed to the stylesheet as a parameter, for example where a sort key is determined
dynamically.</p>
      <p>The static context for the expression includes all the in-scope namespaces, types, and functions from the
calling stylesheet or query. It does <b>not</b> include any variables from the calling environment. 
The base URI and default function namespace are inherited from the calling environment. The default
namespace for elements and types is taken from the value of the <code>xpath-default-namespace</code>
attribute in the stylesheet, if present.</p>
      <p>The expression may contain references to variables 
<code>$p1</code>, <code>$p2</code>, etc., and the values of these variables may be supplied in the
second, third, and subsequent arguments to the <code>saxon:evaluate()</code> call.</p>
      <p>The function <code>saxon:evaluate(string)</code> is shorthand for <code>saxon:eval(saxon:expression(string))</code>.
For the rules governing what may and may not appear in the expression, 
see <a class="bodylink" href="../../extensions/functions/expression.xml">saxon:expression</a>.</p>
      <p>See also <a class="bodylink" href="../../extensions/functions/evaluate-node.xml">saxon:evaluate-node</a>,
which is a similar function intended for evaluating XPath expressions contained in a source document.</p>
      <table width="100%">
         <tr>
            <td>
               <p align="right"><a class="nav" href="evaluate-node.xml">Next</a></p>
            </td>
         </tr>
      </table>
   </body>
</html>