XML technologies / XPath / XPath 2.0: language reference / Path expressions: axes / Ancestor-or-self axis
(Excerpt from "XSLT 2.0 & XPath 2.0" by Frank Bongers, chapter 4.)
Defined for: XPath 1.0 and 2.0 (not in XQuery 1.0)
Direction: reverse
Axis identifier: ancestor-or-self
Abbreviated syntax: none
Figure: the ancestor-or-self axis.
The ancestor-or-self axis contains the context node and all its ancestors, including the document node. Apart from the context node, which may be a text, attribute or other node, it contains only element nodes.
Example:
ancestor-or-self::mein_element
tests the current node and all its ancestors, selecting all element nodes namedmein_element, including the context node if it meets this condition. The result is in reverse document order because this is a reverse axis. The document node is also tested but not selected here, because it has no name.
ancestor-or-self::node()
tests the current node and all its ancestors, selecting every node regardless of kind, including the document node. Apart from possibly the context node, these are element nodes. The sequence is in reverse document order.
Copyright © Galileo Press, Bonn 2008
You may print the online version for private use.
Otherwise, this chapter from "XSLT 2.0 & XPath 2.0 ― Das umfassende Handbuch" is subject to the same terms as the bound edition: the work and all its parts are protected by copyright. All rights reserved, including reproduction, translation, microfilming, storage and processing in electronic systems.
Galileo Press, Rheinwerkallee 4, 53227 Bonn