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
9.9Mb 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

Fifteen Love by R. M. Corbet
Catch the Lightning by Catherine Asaro
The Sanctuary Seeker by Bernard Knight
Songs of the Dancing Gods by Jack L. Chalker
Pendragon by Catherine Coulter
Homecoming by Heath Stallcup
The Unsettled Dust by Robert Aickman