XML technologies / XPath / XPath introduction / Node types & axes

Node types

The components of XML documents are referred to as nodes. There are 7 node types whose names are self-explanatory:

  • Root node: is not to be confused with the root element itself. The root node is rather the virtual parent node of the root element.

  • Element node

  • Attribute node

  • Text node

  • Namespace node

  • Processing instruction node

  • Comment node

Each of these nodes can be accessed with XPath and thus enables a processing with XSL.

Axes

The navigation in a XML document via XPath starts from a context node – in the following pictures referred to as SELF. The context node is always the initial point where the XSLT processor is currently situated. In this example, the names of the axes refer to family relationships – as already common for XML. In the following pictures eleven of the thirteen different axes are illustrated. Apart from the axes, which allow the navigation via the element nodes of a document tree, there are also attribute nodes and the namespace node of an element which are addressed by using the key words attribute or namespace.

The self axis contains the context node.

Self-Axis

The child axis contains all child elements of the context node.

Child-Axis

The descendant axis contains all descendants of the context node.

Descendant-Axis

The descendant-or-self axis contains all descendants and the context node itself.

Descendant-or-self-Axis

The parent axis contains all parent elements of the context node.

Parent-Axis

The ancestor axis contains all ancestors of the context node.

Ancestor-Axis

The ancestor-or-self axis contains all ancestors and the context node itself.

Ancestor-or-self-Axis

The preceding axis contains all predecessors of the context node which are no ancestors. The following axis contains all followers which are no descedants.

Preceding-Axis

The preceding-sibling axis contains all predecessors of the context node which have the same parent element, which means they are the preceding siblings. The following-sibling axis contains all followers of the context node which have the same parent element, which means they are the following siblings.

Preceding-sibling-Axis

back to top