XML technologies / XPath / XPath 2.0: language reference / XPath expressions: the evaluation context / Static context
(Excerpt from "XSLT 2.0 & XPath 2.0" by Frank Bongers, chapter 4.)
The static context is determined before processing. For XPath expressions this is also called static analysis. Static analysis can detect errors in an XPath expression, which are therefore called static errors (static errors). If a static error occurs, an XSLT processor rejects processing of a stylesheet.
All static-context components are described as global: they remain unchanged throughout processing.
Components of the static context
The static context includes the available information about the namespaces (in-scope namespaces) valid during processing, including prefix-bound namespaces and the default namespace or the namespace associated with functions. This information is needed to expand QNames during processing.
The schema information also belongs to the static context. This covers declarations (in-scope element declarations, in-scope attribute declarations) as well as schema and type definitions (in-scope schema definitions, in-scope type definitions).
Variable declarations and references to them are also considered within the static context (in-scope variables). A reference to a variable outside its scope is therefore a static error, even inside an XPath expression that would not be evaluated at run time. Static-context variables may be defined globally for a stylesheet or locally for a template.
Variables declared in XPath expressions belong to the dynamic context:
An exception is variables declared in for expressions within an XPath expression. These variables belong to the dynamic context.
The functions callable from XPath expressions, specifically information about their names and the number and types of their arguments, also belong to the static context (in-scope functions). These include constructor functions for the valid types.
The static context also includes so-called collections: lists of external documents and collections known to the application (statically-known documents and statically-known collections). These may be lists of URIs identifying available documents.
The documents or collections need not actually be available at run time. The list of documents that are actually available therefore belongs to the dynamic context.
The base URI is also specified in the static context. It resolves relative URIs during processing, for example through function fn:resolve-uri().
The final static-context component concerns collations used to compare strings. A collation contains rules for comparing two strings or sorting several strings. It specifies, for example, alphabetical order: whether 'ä' is treated as 'ae' or as a separate letter after z, or whether 'ß' and 'ss' are equivalent in comparisons. This component includes all collations available by name to the relevant functions (in-scope collations) and the default collation used otherwise. If the system environment defines no default collation, applications should use a standardized Unicode collation, the Unicode Codepoint Collation.
The above applies to XPath in general. During an XSLT transformation, XPath’s static context is extended with components used by XSLT functions. These include:
the set of declared key definitions (set of keys)
the set of declared number formats
the set of system properties (system properties)
the list of available instructions
the list of media types used by function
document().the collection of available unparsed text resources (unparsed text resources)
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