saxonica.com

Axis steps

The basic primitive for accessing a source document is the axis step. Axis steps may be combined into path expressions using the path operators / and //, and they may be filtered using filter expressions in the same way as the result of any other expression.

An axis step has the basic form axis :: node-test, and selects nodes on a given axis that satisfy the node-test. The axes available are:

ancestor

Selects ancestor nodes starting with the current node and ending with the document node

ancestor-or-self

Selects the current node plus all ancestor nodes

attribute

Selects all attributes of the current node (if it is an element)

child

Selects the children of the current node, in documetn order

descendant

Selects the children of the current node and their children, recursively (in document order)

descendant-or-self

Selects the current node plus all descendant nodes

following

Selects the nodes that follow the current node in document order, other than its descendants

following-sibling

Selects all subsequent child nodes of the same parent node

namespace

Selects all the in-scope namespaces for an element (this axis is deprecated in XPath 2.0, but Saxon continues to support it)

parent

Selects the parent of the current node

preceding

Selects the nodes that precede the current node in document order, other than its ancestors

preceding-sibling

Selects all preceding child nodes of the same parent node

self

Selects the current node

When the child axis is used, child:: may be omitted, and when the attribute axis is used, attribute:: may be abbviated to @. The expression parent::node() may be shortened to ..

The expression . is no longer synonymous with self::node(), since it may now select items that are not nodes. If the context item is not a node, any use of a path expression will raise an error.

The node-test may be, for example:

Next