# XPath 3.0 changes

Support for XPath 3.0 (previously known as XPath 2.1) is provided. To enable this, call `setLanguageVersion("2.1")` on the s9api `XPathCompiler`, or equivalent calls on the `net.sf.saxon.sxpath.XPathEvaluator`. Within XSLT, XPath 3.0 syntax is supported if the version attribute on the principal stylesheet module is set to "3.0". From JAXP XPath interfaces, support for XPath 3.0 is supported by casting the `XPath` object to `net.sf.saxon.xpath.XPathEvaluator` and calling `xpath.getStaticContext().setXPathLanguageLevel(new DecimalValue("2.1"))`.

The following features are available when XPath 3.0 is enabled:

- The let expression (`let $x := expr, $y := expr return expr`).

- The new context-independent QName syntax (`"uri":local`, also `"uri":*`)

- Facilities associated with higher-order functions: function literals, partial function application, dynamic function invocation, inline functions, plus associated functions such as `map()`, `filter()`, `fold-left()`, and `fold-right()`.

- New functions and operators: see Changes to functions and operators

- Enhancements to regular expressions (non-capturing groups `(?:xxxx)`) and flags (the `q` flag)

The s9api API, together with lower-level APIs for running XPath (including the `StaticContext` interface) have been enhanced to allow the required type of the context item to be supplied as a property of the static context.

Next