Axes

There are twelve axes along which a location step can move. Each selects a different subset of the nodes in the document, depending on the context node. These are:

self

The node itself.

child

All child nodes of the context node. (Attributes and namespaces are not considered to be children of the node they belong to.)

descendant

All nodes completely contained inside the context node (between the end of its start-tag and the beginning of its end-tag); that is, all child nodes, plus all children of the child nodes, and all children of the children’s children, and so forth. This axis is empty if the context node is not an element node or a root node.

descendant-or-self

All descendants of the context node and the context node itself.

parent

The node which most immediately contains the context node. The root node has no parent. The parent of the root element and comments and processing instructions in the document’s prolog and epilog is the root node. The parent of every other node is an element node. The parent of a namespace or attribute node is the element node that contains it, even though namespaces and attributes aren’t children of their parent elements.

ancestor

The root node and all element nodes that contain the context node.

ancestor-or-self

All ancestors of the context node and the context node itself.

preceding

All non-attribute, non-namespace nodes which come before the context node in document order and which are not ancestors of the context node

preceding-sibling

All non-attribute, non-namespace nodes which come before the context node in document order and have the same parent node

following

All non-attribute, non-namespace nodes which follow the context node in document order and which are not descendants of the context node.

following-sibling

All non-attribute, non-namespace nodes which follow the context node in document order and have the same parent node

attribute

Attributes of the context node. This axis is empty if the context node is not an element node.

namespace

Namespaces in scope on the context node. This axis is empty if the context node is not an element node.


Previous | Next | Top | Cafe con Leche

Copyright 2002 Elliotte Rusty Harold
Elliotte Rusty Harold
Last Modified October 15, 2002