3

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!!!

lospejos
  • 1,976
  • 3
  • 19
  • 35
Yahya Uddin
  • 26,997
  • 35
  • 140
  • 231
  • 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 Jul 18 '17 at 04:00

2 Answers2

4

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.

Michael Kay
  • 156,231
  • 11
  • 92
  • 164
  • @Michael. Are you sure? The docs say: "From Saxon 9.7, Saxon supports XPath 3.1 by default. Some features vary by Saxon edition: higher-order functions require Saxon-PE or higher, and schema-awareness requires Saxon-EE." See: http://www.saxonica.com/html/documentation/expressions/xpath31new.html – Stefan Feb 23 '16 at 18:35
1

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.

ruvim
  • 7,151
  • 2
  • 27
  • 36