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
12.12Mb size Format: txt, pdf, ePub
ads
  • 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.

BOOK: XSLT 2.0 and XPath 2.0 Programmer's Reference, 4th Edition
12.12Mb size Format: txt, pdf, ePub
ads

Other books

The Emerald Prince by Morgan, Kayci
Whistling Past the Graveyard by Jonathan Maberry
For Lovers Only by Alex Hairston
Steel and Sorrow by Joshua P. Simon
Lady Churchill's Rosebud Wristlet No. 22 by Gavin J. Grant, Kelly Link
Whole Health by Dr. Mark Mincolla
West of Tombstone by Paul Lederer
Symbiography by William Hjortsberg
The Passenger by Jack Ketchum