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

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

An axis step selects a set of nodes that are related in some way to the context node: for example, the children, the parent, or the following siblings of the context node. The relationship in question is called an axis. An axis is essentially a one-to-many relationship between nodes. If you prefer, you can think of it as a function which takes a single node as input, and produces a sequence of related nodes (for example, the children, the attributes, or the ancestors of that node) as output. Because axes are used so frequently and could be said to be the core feature of the XPath language, we don't use the standard function call syntax, but the underlying theory can be expressed in purely functional terms.

An axis step has three parts: the axis, the node test, and the predicates. The axis and the predicates can be defaulted, but the node test is always present. These three parts are discussed in more detail in the sections that follow: axes on page 609, node tests on page 613, and predicates on page 617. In this section, we'll start with an overview.

A step is based on a particular axis, and it can also choose to filter the nodes that are present on the axis. There are two kinds of filter that can be used, alone or in combination:

  • A node test allows nodes to be selected according to the kind of node, the name and namespace of the node, and (as we shall see in Chapter 11) the type annotation of the node, as determined by schema validation.
  • The step can also include general-purpose predicates, which can specify an arbitrary boolean condition that a node must satisfy, or can select nodes at particular positions in the sequence returned by the axis.

The next section gives the syntax of axis steps.

Syntax of Axis Steps

Expression
Syntax
AxisStep
(ForwardStep | ReverseStep) PredicateList
PredicateList
Predicate *
Predicate
[
Expr
]
ForwardStep
(ForwardAxis NodeTest) | AbbrevForwardStep
ReverseStep
(ReverseAxis
NodeTest)
|
AbbreReverseStep
ForwardAxis
child ::
|
descendant
::
|
attribute
::
|
self
::
|
descendant-or-self
::
|
following-sibling
::
|
following
::
|
namespace

Other books

You by Joanna Briscoe
Breathe by Tracey E. Chambers
Virtue's Reward by Jean R. Ewing
Plus One by Christopher Noxon
Zombie Bums from Uranus by Andy Griffiths
Fresh Tracks by Georgia Beers
Found You by Mary Sangiovanni
Dirty Angels 01 by Karina Halle
An Ordinary Decent Criminal by Michael Van Rooy