# xsl:evaluate

The `xsl:evaluate` instruction is new in XSLT 2.1. 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 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 is fully implemented in Saxon 9.3 with the following exceptions:

- Functions available only in XSLT, such as key(), cannot be used in the target XPath expression.

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

Attributes:

- xpath: an expression, which is evaluated to return the target expression as a string.

- base-uri: a string (as an AVT), gives the base URI for the target expression. Defaults to the base URI of the stylesheet instruction.

- namespace-context: an expression returning a node; the in-scope namespaces of this node define the namespace context for the XPath expression. Defaults to the namespace context of the `xsl:evaluate` instruction in the stylesheet

- as: a SequenceType: defines the required type of the result of the XPath expression. Defaults to `item()*`

- schema-aware: "yes" or "no", as an AVT: if "yes", the XPath expression has access to the schema components imported into the stylesheet.

Children:

- `xsl:with-param`: defines variables that the target expression can use.

- `xsl:fallback`: defines fallback behaviour when using an XSLT 2.0 (or 1.0) processor.

Next