The XPath Context

The context in an XPath expression consists of several things:

Context node

The node currently being evaluated. [2.0] If the context item is a node, the context node is the same as the context item. If the context item is an atomic value, the context node is undefined.

[2.0] Context item

The item currently being evaluated. This is the equivalent of the context node in XPath 1.0; the name reflects the fact that the context can be focused on an atomic value instead of a node.

Context position

A nonzero positive integer that indicates the position of the context node within the set of context nodes. The XPath function position() returns the context position.

Context size

A nonzero positive integer that indicates the number of nodes in the current context. The XPath function last() returns the context size.

Variable bindings

A set of variables that are in scope for the current context. Each one is represented by a variable name and an object that represents its value.

Functions

A set of functions visible to the current context. Each function is represented by a mapping between a function name and the actual code to be invoked. Each function takes zero or more arguments and returns a single result. XPath defines a number of core functions that are always available; XSLT defines additional functions that go beyond those defined in the XPath specification. Any extension functions defined in the stylesheet are visible as well.

Namespace declarations

The set of namespace declarations ...

Get XSLT, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.