Allows XPath expressions to be constructed and evaluated dynamically at runtime.
evaluate($xpath as xs:string, $param1 as item()*, $param2 as item()*, $param3 as item()*) ➔ item()*
The XPath expression to be evaluated
The value to be bound to $p1
The value to be bound to $p2
The value to be bound to $p3 ...
The number of arguments is variable (1 or more).
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.
The static context for the expression includes all the in-scope namespaces, types, and functions from the
calling stylesheet or query. It does not 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
attribute in the stylesheet, if present.
The expression may contain references to variables
$p2, etc., and the values of these variables may be supplied in the
second, third, and subsequent arguments to the
saxon:evaluate(string) is shorthand for
For the rules governing what may and may not appear in the expression,
see the details of
which is a similar function intended for evaluating XPath expressions contained in a source document.
Notes on the Saxon implementation
Fully implemented. Note that an
xsl:evaluate instruction with similar functionality is available
as a standard feature in XSLT 3.0.