XML technologies / XSLT / Introduction to XSLT 2.0 / Getting started with XSLT and XPath / Path expressions – examples / Skipping levels: The expression //
(Excerpt from "XSLT 2.0 & XPath 2.0" by Frank Bongers, Chapter 1.)
To select a node-set across several document levels, when positions are unknown or nodes appear at different levels, use the abbreviation // representing a neutral step on the Descendant-Or-Self axis.
//gruss
This selects all elements<gruss>, wherever they occur in the document. Since the expression starts with a slash, it is also absolute.hallo//gruss
This selects all elements<gruss>, located anywhere inside an element<hallo>one level below the context. Warning: It also includes elements directly contained as children in<hallo>. No intermediate step is required (//is neutral).
Note: the character sequence//is, unlike/, not a complete expression by itself, but only an abbreviation for the longer axis specifier/descendant-or-self::node()/. A following Location Step is always required, usually a step on the Child axis.//*
This expression starts at the document node and selects all elements in the document, including the root element. The document node itself is excluded, since it is not an element. Written out in full:
/descendant-of-self::node()/child::*
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