3
votes

I am currently using XPath 3.1 syntax but for some reason Saxon outputs the error:

To use XPath 3.1 syntax, you must configure the XPath parser to handle it.

How do I do this?

Many thanks!!!

2
An update: the XSLT 3.0 Recommendation and Saxon 9.8 were released on the same day, 8 June 2017, and Saxon 9.8 supports XPath 3.1 unconditionally (in all editions).Michael Kay

2 Answers

4
votes

If you're using the s9api API, use XPathCompiler.setLanguageVersion("3.1").

If you're using JAXP, that's probably a bad idea because the JAXP XPath API can't handle the richness of XPath 3.1 data types; but if you must, cast the XPath object to net.sf.saxon.xpath.XPathEvaluator; then call getStaticContext().setXPathLanguageLevel().

In Saxon 9.7 the default XPath language level supported is 3.0, because that's the latest W3C spec that has reached Recommendation status.

UPDATE

In Saxon 9.8, XPath 3.1 is the default.

1
votes

In case of XSLT and Saxon-HE 9.7.0.3J, it works by using -xsltversion:3.0 command-line option or version="3.0" attribute of the document element.