XML technologies / XSLT / Introduction to XSLT 2.0 / Getting started with XSLT and XPath / Getting started with XPath: path expressions / Reference point: The path expression in context
(Excerpt from "XSLT 2.0 & XPath 2.0" by Frank Bongers, Chapter 1.)
Here is the exact sequence of events once more:
When the template rule
match="/"is activated, the parser enters the source document tree, specifically its document node. It faces towards the root element.An element named
<gruss>is sought to retrieve its string value.
In detail: the XSLT processor activates the template rule match="/" and moves, as it were, to the threshold of the input document, without entering it yet. It stays at that position, which forms the evaluation context during processing of the template rule.
The current node thus provides the basis for evaluating XPath expressions within the template rule. Starting from that node, the processor evaluates a path expression in the current template rule.
The Pattern in this case is /, so the context is the source document’s document node. The XPath expression gruss must be considered relative to this context. Combining the context and expression conceptually gives:
/ + gruss -> /gruss
This resembles a file path, and with good reason: XPath is indeed based on UNIX file-path syntax. A leading slash denotes the root of the system directory there, and the XML document’s document node here. It does not denote the root element, which lies one level further in. Interpreted this way, the compound expression above means:
“An element <gruss> at the first (topmost) level of the document tree”
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