XML technologies / XPath / XPath 2.0: language reference / Path expressions: location steps / Constructing the result sequence
(Excerpt from "XSLT 2.0 & XPath 2.0" by Frank Bongers, chapter 4.)
A path expression containing just one step constructs its result sequence directly. It contains nodes satisfying that step’s condition relative to the current context node, or the document node for an absolute path. This is called a simple path expression.
Multiple steps joined by the path operator form a composite path expression (composite path expression). Constructing its result is less straightforward because the focus changes at each step.
Each location step, evaluated from left to right, creates a node sequence. Its items become context nodes in turn, providing temporary starting points for evaluating the next step. The context node therefore moves through the expression as the evaluation context. After the final step, the focus returns to the original context node.
If step_1 produces a sequence of n nodes, step_2 is evaluated exactly n times, using nodes 1 through n of the primary sequence as context nodes in turn. This repeats until the end of the chain.
The union of all nodes successfully tested by the final step forms the path expression’s result sequence. It need not cover a contiguous tree region: its nodes may be scattered throughout the document.
Every node in the result sequence satisfies all the steps of the path expression. All nodes throughout the document that meet these conditions are included: in this sense, an XPath path expression is inclusive (inclusive).
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