11.4 Top-level Variables and Parameters
Top-level Variables and Parameters
Both xsl:variable and xsl:param are
allowed as Top-level elements.
A top-level variable-binding element declares a global variable that
is visible everywhere. A top-level xsl:param element
declares a parameter to the stylesheet; XSLT does not define the
mechanism by which parameters are passed to the stylesheet. It is an
error if a stylesheet contains more than one binding of a top-level
variable with the same name and same Import Precedence. At the
top-level, the expression or template specifying the variable value is
evaluated with the same context as that used to process the root node
of the source document: the current node is the root node of the
source document and the current node list is a list containing just
the root node of the source document. If the template or expression
specifying the value of a global variable x references a
global variable y, then the value for y must
be computed before the value of x. It is an error if it
is impossible to do this for all global variable definitions; in other
words, it is an error if the definitions are circular.
This example declares a global variable para-font-size,
which it references in an attribute value template.
<xsl:variable name="para-font-size">12pt</xsl:variable>
<xsl:template match="para">
<fo:block font-size="{$para-font-size}">
<xsl:apply-templates/>
</fo:block>
</xsl:template>
|