Defines a variable. If
<xsl:variable> occurs as a top-level
element, it is a global variable that is accessible throughout the
stylesheet. Otherwise, the variable is local and exists only in the
element that contains the
<xsl:variable>. The value of the
variable can be defined in one of two ways: specified in the
select attribute or defined in an XSLT
template inside the
<xsl:variable> element itself. If
neither method is used, the value of the variable is an empty
Either a top-level element or an instruction.
An attribute that names this variable.
An XPath expression that defines the value of this variable.
The datatype of the variable. For example,
integer" select="11"/> defines
a new variable of type
integer. It is an error if the
supplied value can’t be converted to the specified type; using
old'" here would cause an error. If you’re using a
schema-aware XSLT processor, you can use
your own datatypes.
element can be empty or it can contain an XSLT template. It is a fatal
error if it contains both content and a
<xsl:stylesheet> as a
top-level element or in a template.
[1.0] XSLT section 11, “Variables and Parameters.”
[2.0] XSLT section 9, “Variables and Parameters.”
Here is a stylesheet that defines a number of variables: