Axis steps

An axis step consists of three parts: an optional axis, a node test, and zero or more predicates.

The node test specifies the criteria used to select nodes. The predicates filter the sequence that is returned by the axis step.

The result of an axis step is always a sequence of zero or more nodes, and these nodes are returned in document order. An axis step can be either a forward step, which starts at the context node and moves down through the XML tree, or a reverse step, which starts at the context node and moves up through the XML tree. If the context item is not a node, then the expression results in a type error.

The unabbreviated syntax for an axis step consists of an axis name and node test that are separated by a double colon. The syntax of an axis expression can be abbreviated by omitting the axis and using shorthand notations.

Syntax

axis-step
Read syntax diagramSkip visual syntax diagramaxisxmlname-testxmlkind-testpredicate-list
axis
Read syntax diagramSkip visual syntax diagramchild::@attribute::descendant::self::descendant-or-self::parent::
xmlname-test
Read syntax diagramSkip visual syntax diagramxml-qualified-namexml-wildcard
xml-wildcard
Read syntax diagramSkip visual syntax diagram*xml-nsprefix:**:xml-ncame
xmlkind-test
Read syntax diagramSkip visual syntax diagramdocument-node(element(name*))element(name*)attribute(name*)processing instruction(xml-ncnameprocessing-instruction-literal-string)comment()text()node()
predicate-list
Read syntax diagramSkip visual syntax diagram[expression]

Example

In the following example, child is the name of the axis and price is the name of the element nodes to be selected on this axis.
child::price
The axis step in this example selects all price elements that are children of the context node.