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

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.

Other books

Katie's Dream by Leisha Kelly
The Garden Party by Peter Turnbull
The Ruby Tear by Suzy McKee Charnas
It Was Me by Cruise, Anna
Fates and Traitors by Jennifer Chiaverini
The Sword of Darrow by Hal Malchow
The Billionaire's Gamble by Elizabeth Lennox
The Missing Book by Lois Gladys Leppard