The location paths of XPath 1.0 are referred to in XPath 2.0 as path expressions. Informally, a path expression is a sequence of steps separated by the "/
" operator, for example a/b/c
(which is short for child::a/child::b/child::c
). More formally, however, "/
" is simply a binary operator that applies the expression on its right-hand side to each item in turn selected by the expression on the left hand side. So in this example, the expression a
selects all the element children of the context node that are named ; the expression
child::b
is then applied to each of these nodes, selecting all the children of the
elements; and the expression
child::c
is then applied to each node in this sequence, which selects all the
children of these elements.
The "/
" operator is generalized in XPath 2.0 to allow any kind of expression to be used as an operand: in XPath 1.0, the right-hand side was always an axis step. For example, a function call can be used on the right-hand side. The typing rules for the operator require that the result of the first operand is a sequence of nodes. The right hand operand can return either nodes or atomic values (but not a mixture). If the result consists of nodes, then duplicates are eliminated and the nodes are returned in document order, an ordering defined in terms of the relative positions of the nodes in the original XML tree.
In many cases the operands of "/
" will be axis steps: these are largely unchanged from XPath 1.0, and are described in the article on XPath 1.0.
Read more about this topic: XPath 2.0
Famous quotes containing the words path and/or expressions:
“The gray-eyed morn smiles on the frowning night,
Checkring the eastern clouds with streaks of light,
And fleckled darkness like a drunkard reels
From forth days path and Titans fiery wheels.”
—William Shakespeare (15641616)
“The expressions of the poet cannot be analyzed; his sentence is one word, whose syllables are words. There are indeed no words quite worthy to be set to his music. But what matter if we do not hear the words always, if we hear the music?”
—Henry David Thoreau (18171862)