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:

  1. When the template rule match="/" is activated, the parser enters the source document tree, specifically its document node. It faces towards the root element.

  2. 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”

   

back to top