The xsl:evaluate instruction is new in XSLT 3.0. It allows dynamic evaluation of XPath expressions constructed as a string, in the same way as the saxon:evaluate() extension function that has been available in Saxon for many years.

The following example sorts product elements according to a sort key supplied (in the form of an XPath expression) as a parameter to the stylesheet.

<xsl:apply-templates select="product"> <xsl:sort> <xsl:evaluate select="$product-sort-key"/> </xsl:sort> </xsl:apply-templates>

The functionality is available as an XSLT instruction, rather than a function, to allow more flexibility in the syntax, in particular the ability to define parameters using xsl:with-param child elements.

The instruction has been fully implemented since Saxon 9.3 with the following exceptions:

The instruction may take an xsl:fallback to define fallback behaviour when using an XSLT 2.0 processor.