Read XSLT 2.0 and XPath 2.0 Programmer's Reference, 4th Edition Online
Authors: Michael Kay
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:
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 |