XML technologies / XPath / XPath 2.0: language reference / Path expressions: axes / 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: self
Abbreviated syntax: .
Figure: the self axis.
The self axis contains exactly one node: the current context node, which need not be an element. The full expression self::node() can be replaced by the equivalent abbreviated dot expression “.”.
Example:
The double colon “::” is the joining operator between the axis identifier and node test. It is not part of the axis identifier.
self::node()
selects the current node regardless of kind or name. The result therefore always contains one node, even if the context item is neither an element nor a document node.
self::*
selects the context node if it is an element or document node. If it is of another kind, such as text, the result sequence is empty.
.
This abbreviated expression is equivalent toself::node()and therefore returns a one-item sequence containing the context node. Strictly speaking, “.” is a placeholder for the context item rather than an abbreviation for the self axis. It is equivalent toself::node()only when the context item is a node. Otherwise,self::node()causes a type error (err:XPTY0020).
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