XPath Axis Types

ancestor

This axis type contains all ancestors of the current context node. This includes parent nodes, grandparents, and so on. Therefore, the ancestor axis always contains the root node unless root is the context node.

Example:

ancestor::chapter/intro 

ancestor-or-self

Like the ancestor axis, this axis selects all ancestors of the context node, including parent nodes, grandparents, and so on. In addition, ancestor-or-self contains the context node itself.

Example:

ancestor-or-self::node() 

attribute

When the context node is an element node, the attribute axis contains the attributes of this node. For all other node types, the axis is empty.

Example:

attribute::href 

child

Selects children of the context node.

Example: ...

Get Special Edition Using XSLT now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.