# Variable References

The value of a variable (local or global variable, local or global parameter) may be referred to using the construct `$name`, where name is the variable name.

The variable is always evaluated at the textual place where the expression containing it appears; for example a variable used within an `xsl:attribute-set` must be in scope at the point where the attribute-set is defined, not the point where it is used.

A variable may take a value of any data type, and in general it is not possible to determine its data type statically.

It is an error to refer to a variable that has not been declared.

Starting with XPath 2.0, variables (known as range variables) may be declared within an XPath expression, not only using `xsl:variable` elements in the stylesheet. The expressions that declare variables are the `for`, `some`, and `every` expressions.

Expand | Next