Search code examples
xpathsaxonxpath-2.0

Is XPath 3.1 100% upwardly compatible with XPath 2.0?


We are using Saxon, calling it from Java, to perform queries. When we upgrade to XPath 3.1, will it handle all queries written for XPath 2.0 the same as before? Or are there changes in what is returned for some queries?

I'm asking because if it's 100% upwardly compatible, we just change our existing XPath 2.0 code to use XPath 3.1. But if it's different, then we need to add XPath 3.1 as a new datasource type.

We do have XPath 1.0 as a distinct datasource because there are differences between what XPath 1.0 and 2.0 return for some queries.


Solution

  • You can assure this premise by following this chain:

    XPath-3.0 is backwards compatible to XPath-2.0

    This appendix provides a summary of the areas of incompatibility between XPath 3.0 and [XML Path Language (XPath) Version 1.0]. In each of these cases, an XPath 3.0 processor is compatible with an XPath 2.0 processor.

    XPath-3.1 is backwards compatible to XPath-3.0.

    This Recommendation specifies XPath version 3.1, a fully compatible extension of XPath version 3.0.