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

Other books

THE DEEP END by Mulhern, Julie
He, She and It by Marge Piercy
The Green Knight by Iris Murdoch
The Puppetmasters by Lamb, K. D.
A Colossal Wreck by Alexander Cockburn
According to Hoyle by Abigail Roux
Liz Carlyle - 06 - Rip Tide by Stella Rimington
A Feast in Exile by Chelsea Quinn Yarbro