Reference: XPath syntax
This section is an informal guide to the syntax of XPath expressions, which are used in Saxon both within XSLT stylesheets, and as parameters to various Java interfaces. XPath is also a subset of XQuery. For formal specifications, see the XPath 2.0, XPath 3.0, and XPath 3.1 specifications.
New features in XPath 3.0 and 3.1
An important new feature in XPath 3.1 is the definition of maps and arrays. These features are available in all current Saxon editions, whether you are using XPath, XQuery, or XSLT. A major motivation for their introduction was to support the data structures that can be defined in JSON, but they have many other uses where more complex data structures need to be built. For more details see Maps in XPath and Arrays in XPath.
In XPath 2.0 (and higher) all values are considered as sequences. A sequence consists of zero
or more items; an item may be a node or an atomic value, or in 3.0 it may also be a function
item. Examples of atomic values are integers, strings, booleans, and dates. A single value
such as a number is considered as a sequence of length 1. The empty sequence is written as
(); a singleton sequence may be written as
("a"), and a general sequence is written as
("a", "b", "c").
The node-sets of XPath 1.0 are replaced in XPath 2.0 by sequences of nodes. Path expressions will return node sequences whose nodes are in document order with no duplicates, but other kinds of expression may return sequences of nodes in any order, with duplicates permitted.
The functions provided in the XPath function library are listed separately: see the Function library section. This section summarizes the following syntactic constructs and operators provided in XPath 2.0 and higher: