saxon:evaluate

Allows XPath expressions to be constructed and evaluated dynamically at run-time.

evaluate($xpath as xs:string, $param1 as item()*, $param2 as item()*, $param3 as item()*) ➔ item()*

Arguments

 

$xpath

xs:string

The XPath expression to be evaluated

 

$param1

item()*

The value to be bound to $p1

 

$param2

item()*

The value to be bound to $p2

 

$param3

item()*

The value to be bound to $p3 ...

Result

item()*

Namespace

http://saxon.sf.net/

Saxon availability

Requires Saxon-PE or Saxon-EE.

Notes on the Saxon implementation

Available since before Saxon 7.2. Dropped in 12.0, but then reinstated in 12.4 for the benefit of XQuery users, where the xsl:evaluate instruction is not available. Note that an xsl:evaluate instruction with similar functionality is available as a standard feature in XSLT 3.0.

Details

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

If stylesheet functions are to be called from the expression, they should be declared with visibility="public".

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 the details of saxon:expression.

See also:

saxon:expression()