saxonica.com

saxon:evaluate()

saxon:evaluate($in as xs:string [, $paramN as item()* ...]) ==> item()*

This function allows XPath expressions to be constructed and evaluated dynamically at runtime.

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 xpath-default-namespace attribute in the stylesheet, if present.

The expression may contain references to variables $p1, $p2, etc., and the values of these variables may be supplied in the second, third, and subsequent arguments to the saxon:evaluate() call.

The function saxon:evaluate(string) is shorthand for saxon:eval(saxon:expression(string)). For the rules governing what may and may not appear in the expression, see saxon:expression.

See also saxon:evaluate-node, which is a similar function intended for evaluating XPath expressions contained in a source document.

Next