W3cubDocs

/XSLT & XPath

xsl:variable

XSLT/XPath Reference: XSLT elements, EXSLT functions, XPath functions, XPath axes

The <xsl:variable> element declares a global or local variable in a stylesheet and gives it a value. Because XSLT permits no side-effects, once the value of the variable has been established, it remains the same until the variable goes out of scope

Syntax

<xsl:variable name=NAME select=EXPRESSION >
	TEMPLATE
</xsl:variable> 

Required Attributes

name
Gives the variable a name.

Optional Attributes

select
Defines the value of the variable through an XPath expression. If the element contains a template, this attribute is ignored.

Type

Top-level or instruction. If it occurs as a top-level element, the variable is global in scope, and can be accessed throughout the document. If it occurs within a template, the variable is local in scope, accessible only within the template in which it appears.

Defined

XSLT, section 11.

Gecko support

Supported.

© 2005–2017 Mozilla Developer Network and individual contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/XSLT/variable