XML technologies / XPath / XPath 2.0: language reference / Path expressions: axes / Parent axis
(Excerpt from "XSLT 2.0 & XPath 2.0" by Frank Bongers, chapter 4.)
Defined for: XPath 1.0 and 2.0, XQuery 1.0
Direction: reverse
Axis identifier: parent
Abbreviated syntax: ..
Figure: the parent axis.
The parent axis contains the context node’s parent node (parent), if one exists, which is the case for every node except the document node. Because the document tree is a directed graph, exactly one parent exists, always an element node.
An element’s parent is the element or document node from which it directly descends; an attribute or namespace node’s parent is the element node to which it belongs.
The parent axis is empty for the document node.
Note: the parent axis can also be used in XQuery
The parent axis is the only reverse axis also defined in XQuery 1.0.
Example:
parent::node()
selects the current node’s element node, regardless of name. The result always contains exactly one element node, unless the context node is the document node itself.
..
abbreviates the context node’s parent. Its result matches the expressionparent::node()above. Technically, “..” is therefore a complete location step.
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