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

BOOK: XSLT 2.0 and XPath 2.0 Programmer's Reference, 4th Edition
9.4Mb size Format: txt, pdf, ePub
ads
::
ReverseAxis
parent
::
|
ancestor
::
|
preceding-sibling
::
|
preceding
::
|
ancestor-or-self
::
|

The split between forward and reverse axes in this grammar is cosmetic. It's presented this way because there are semantic distinctions in the way predicates are evaluated in the two cases, and it's nice when semantic distinctions can be related clearly to syntactic distinctions.

The abbreviations for steps will be covered later (see page 621). For the moment, we'll concentrate on the unabbreviated syntax in which the axis names are spelt out in full.

Effect

A step can be used to follow any axis and to find any kind of node.

Each axis returns a set of nodes relative to a specific origin node, for example, its previous siblings or its ancestors. The axis step returns a subset of the nodes on this axis, selected by the kind of node, the name of the node, the schema-defined type of the node, and the predicate expressions.

The
NodeTest
supplies any restrictions on the node kind, name, and type of the selected nodes, while the predicate expressions provide arbitrary boolean conditions that the nodes must satisfy, or positional filters that constrain their relative position.

The result of an axis step is always a sequence of nodes (possibly an empty sequence) with no duplicates, in document order. This is true even if the axis is one of the reverse axes, such as
preceding-sibling
, that selects nodes that are before the context node in document order.

For example, the step
ancestor::node()
, given any starting node, finds all the ancestors of that node. When the step is used in a path expression such as
$n/ancestor::node()
, it returns a sequence containing all the ancestors of all the nodes in
$n
. The sequence will be in document order, which means that the outermost ancestor (the root of the tree) will appear first in the result.

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

Other books

My Life in Darkness by Harrison Drake
Murder of a Lady by Anthony Wynne
Habitaciones Cerradas by Care Santos
Gone to Ground by Taylor, Cheryl
Fashionably Dead in Diapers by Robyn Peterman
Holy Rollers by Rob Byrnes