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:
“Tired,
she looked up the path
her lover would take
as far as her eyes could see.
On the roads,
traffic ceased
at the end of day
as night slid over the sky.
The travellers pained wife
took a single step towards home,
said, Could he not have come at this instant?
and quickly craning her neck around,
looked up the path again.”
—Amaru (c. seventh century A.D.)
“Whatever offices of life are performed by women of culture and refinement are thenceforth elevated; they cease to be mere servile toils, and become expressions of the ideas of superior beings.”
—Harriet Beecher Stowe (18111896)