XML technologies / XSLT / Introduction to XSLT 2.0 / Getting started with XSLT and XPath / Path expressions – examples / The step to the parent element – the parent axis
(Excerpt from "XSLT 2.0 & XPath 2.0" by Frank Bongers, Chapter 1.)
Movement from the context node to its parent is described by the parent axis. It also has an abbreviation borrowed from UNIX and DOS file syntax: two consecutive dots. This axis selects at most one node, the parent of the context node.
..
This location step selects the context node’s parent. The parent must be an element node or the document node itself. Other node types have no children by definition. The context node, however, can also be a text, attribute, namespace, comment or PI node.parent::node()
This is the full form of the abbreviation above. In general,node()must be used so that the expression can also match the document node.../*
This selects all sibling elements of the context node by first moving back to the parent and then down towards its children. Warning: The context node is also included in the selection, provided it is an element node.
Our discussion of path expressions is not yet complete. For example, accessing attribute values has not yet been explained; that follows on the next pages. It would also be useful to refine conditions and filter similar elements selected by a path expression down to those actually of interest. This is done through filter expressions called predicates, discussed in a later section.
Copyright © Galileo Press, Bonn 2008
You may print the online version for your private use.
Otherwise, this chapter from "XSLT 2.0 & XPath 2.0 ― Das umfassende Handbuch" is subject to the same terms as the printed edition: the work and all its parts are protected by copyright. All rights are reserved, including reproduction, translation, microfilming, and storage and processing in electronic systems.
Galileo Press, Rheinwerkallee 4, 53227 Bonn