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

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


to process the four selected elements in the order indicated.

If there is no contained expression, that is, if the
ParenthesizedExpr
is written as
()
, then its value is the empty sequence. For example, the expression
$a
union
()
returns the union of the sequence
$a
and the empty sequence; this has the effect of returning all the nodes in
$a
, in document order and with duplicates removed. The
union
operator (which can also be written
|
) is described in Chapter 9.

One special case where the meaning of parentheses may not be immediately apparent is in conjunction with predicates. Predicates are used to filter the items in a sequence; for example,
$seq[.>= 0]
selects all the items in the sequence
$seq
whose value is greater than zero. As explained in Chapter 9, the meaning of a predicate is subtly different when it appears as part of an axis step. The result of this distinction is that:

  • ancestor::node()[1]
    selects the innermost ancestor of the context node (that is, its parent)
  • (ancestor::node())[1]
    selects the outermost ancestor of the context node (that is, the root of the tree).

Other books

Everran's Bane by Kelso, Sylvia
The Flying Eyes by J. Hunter Holly
Poisonous Desires by Selena Illyria
The Summer Book by Tove Jansson
Power Play: A Novel by Steel, Danielle
The Secret Side of Empty by Maria E. Andreu
Skeletons by McFadden, Shimeka
True Blue by David Baldacci
Far Horizon by Tony Park
Blind Eye by Stuart MacBride