XSLT 2.0 and XPath 2.0 Programmer's Reference, 4th Edition (446 page)

BOOK: XSLT 2.0 and XPath 2.0 Programmer's Reference, 4th Edition
5.99Mb size Format: txt, pdf, ePub
  • In a path expression, both the input sequence and the step expression are required to return nodes exclusively. A
    for
    expression can work on any sequence, whether it contains nodes or atomic values or both, and it can also return any sequence.
  • Path expressions always sort the resulting nodes into document order, and eliminate duplicates. A
    for
    expression returns the result sequence in the order that reflects the order of the input items.
  • In a path expression, the context item for evaluating a step is set to each item in the input sequence in turn. In a
    for
    expression, the range variable fulfils this function. The context item is not changed. Nor are the context position and size (
    position()
    and
    last()
    ) available to test the position of the item in the input sequence.

Simple mapping expressions use the convenient syntax of path expressions (that is, the
/
operator), but they work on atomic values rather than nodes. Specifically, the expression on the right-hand side of
/
must return a sequence that consists entirely of atomic values. For example, the expression
*/name()
returns a sequence of strings—the names of the child elements of the context node. There is no sorting into document order here, because document order doesn't mean anything for atomic values. The result is exactly the same as the expression
for $x in * return name($x)
, just with a more compact syntax.

Other books

The Old Men of Omi by I. J. Parker
Consumed by Suzanne Wright
Expose! by Hannah Dennison
Under the Kissing Bough by Shannon Donnelly
Bane by Kristin Mayer
Now and Forever by Mary Connealy
Remember by Eileen Cook