O'Reilly logo

XQuery by Priscilla Walmsley

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Differences Between XQuery 1.0/XPath 2.0 and XPath 1.0

XPath 1.0 is a subset of XPath 2.0, which is essentially a subset of XQuery 1.0. If you already know XPath 1.0 from using it in XSLT 1.0, you will probably find parts of XQuery very familiar.

Backward- and cross-compatibility are mostly maintained among the three languages, so that an expression in any of the three languages will usually yield the same results. However, there are a few important differences, which are described in this section. All of these differences between XPath 1.0 and XPath 2.0 are also relevant if you plan to use XSLT 2.0.

The few areas of backward incompatibility between XPath 1.0 and XPath 2.0 are discussed in greater detail in Appendix I of the XPath 2.0 specification, which is at http://www.w3.org/TR/xpath20. In XSLT, you can choose to process 2.0 stylesheets while setting an XPath 1.0 Compatibility Mode to treat XPath expressions just like XPath 1.0 expressions. This helps to avoid unexpected changes in the behavior of stylesheets when they are upgraded from 1.0 to 2.0. The mode is not available in XQuery 1.0, since there is no previous version of XQuery.

Data Model

The XPath 1.0 data model has the concept of a node-set, which is a set of nodes that are always in document order. In XQuery 1.0/XPath 2.0, there is the similar concept of a sequence. However, sequences differ in that they are ordered (not necessarily in document order), and they can contain duplicates. Another difference is that sequences ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required