XML technologies / XSLT / Introduction to XSLT 2.0 / XSLT and XPath – round three / Modular stylesheets / Parameters and variables in imported stylesheets
(Excerpt from "XSLT 2.0 & XPath 2.0" by Frank Bongers, Chapter 3.)
Let us briefly return to variables and parameters. In imported or included stylesheets, they matter here mainly as top-level declarations: global variables and parameters.
Importing or including local variables and parameters
Local variables in imported templates are restricted to their template, so no conflicts arise here. However, a local binding can shadow global variables, including those from the main module. This applies equally to variables and parameters introduced by imported or included template rules.
Importing global parameters and variables
For global variables and parameters, an import may encounter a declaration with the same name in the importing module. This would normally be an invalid binding, but import precedence applies: the imported declaration remains hidden. Its value cannot be accessed, and the processor may choose not to initialize it.
Including global parameters and variables
An included variable declaration is treated as if written at the inclusion point. Declaring another variable with the same name afterwards is a static error. The included declaration always precedes the one originally in the main stylesheet, because of the required position of thexsl:includeelement at the start of the stylesheet. Such duplicates must therefore be avoided
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