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

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

Document Order and Duplicates

There are three kinds of expression in XPath 2.0 whose result is always guaranteed to be a sequence of nodes in document order, with no duplicates. They are all covered in this chapter. Specifically, they are:

  • Any expression using the unary or binary path operator
    /
    , or the pseudo-operator
    //
    , unless the expression on the right-hand-side of the operator returns atomic values rather than nodes
  • Any axis step (even an axis step like
    preceding-sibling::*
    that uses a reverse axis delivers its results in forwards document order)
  • Any expression using one of the binary operators
    union
    ,
    intersect
    , and
    except
    .

The elimination of duplicates is always based on node identity, not value.

Many simple path expressions naturally return results in document order anyway and would never select duplicates. In these cases, the system doesn't have to do any extra work to satisfy this rule. For example, any path expression that does downward selection using the child axis will naturally retrieve the nodes in document order. But it's easy to come up with path expressions that don't have this property; for example,
following-sibling::*/..
selects the parents of all the following siblings, and of course they all have the same parent, so after eliminating duplicates this expression returns at most a single node.

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

Other books

The Strategist by John Hardy Bell
Betrayed by Ednah Walters
Nightmare by Stephen Leather
Hometown Favorite: A Novel by BILL BARTON, HENRY O ARNOLD
Cinders and Ashes by King, Rebecca