XML technologies / XPath / XPath 2.0: language reference / Path expressions: axes / Descendant-or-self 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: forward

Axis identifier: descendant-or-self

Abbreviated syntax: //

The descendant-or-self axis

Figure: the descendant-or-self axis.

The descendant-or-self axis contains the context node and all its direct and indirect descendants. It is the union of the descendant and self axes.

For a document context node, this axis contains the entire document tree.

The descendant-or-self axis also has the abbreviated double-slash syntax “//”. Unlike a single slash, this abbreviation cannot be used without a following node test.

Example:

Caution: the abbreviation alone is not context-sensitive
Used alone, this syntax, unlike the first example’s expression descendant-or-self::*, is not context-sensitive. Only within composite path expressions does the double slash, as an abbreviation for descendant-or-self, produce a context-relative path overall.
When used alone with a following node test, or at the start of a composite path expression, it always produces an absolute path.

   

back to top