Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

XSLT Element

XSLT xsl:variable Element


XSLT Element Reference Manual Complete XSLT Element Reference Manual


Definition and Usage

xsl:variable The element is used to declare a local or global variable.

**Note:** If declared as a top-level element, it is a global variable. If a variable is declared inside a template, it is a local variable.

**Note:** Once you have set the value of a variable, you cannot change or modify it!

**Tip:** You can add a value to a variable through the content of the xsl:variable element or through the select attribute!


Syntax

name="name"

select="expression">

property

property Value Description
name name Required. Specifies the name of the variable.
select expression Optional. Defines the value of the variable.

Example 1

If the select attribute is set, thexsl:variable element cannot contain any content. If the select attribute contains a literal string, the string must be quoted. The following two examples assign the value "red" to the variable "color":

Example 2

If both the xsl:variable If the element contains only the name attribute and has no content, the value of the variable is an empty string:

Example 3

The following example assigns a value to the variable "header" through the content of the xsl:variable element:

xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

Element Description



XSLT Element Reference Manual Complete XSLT Element Reference Manual