var

Syntax

var $name=value;

Description

Declare a local or global variable. If the var statement appears at the top of the script, it is a global variable with a scope covering the entire script. Otherwise, it is a local variable. You can include an initial value by following the variable name with an equal sign (=) and a value expression.

In SLAX, parameter and variable names contain the dollar sign ($) even in the declaration. This is unlike the name attribute of <xsl:variable> and <xsl:parameter> elements.

$name—Specifies the name of the variable. After declaration, the variable can be referred to within expressions using this name, including the $ character.

value—Defines the default value for the variable, which is used if the person or client application that executes the script does not explicitly provide a value.

var $vrf;
var $location = $dot/@location;
var $message = "We are in "_ $location _" now.";
<xsl:variable name="vrf"/>
<xsl:variable name="location" select="$dot/location"/>
<xsl:variable name="message" select="concat('We are in ', $location, now.')"/>

See Example: Limiting the Number of E1 Interfaces, Example: Limiting the Number of ATM Virtual Circuits, Example: Configuring Administrative Groups for LSPs, and Example: Automatically Configuring Logical Interfaces and IP Addresses.

Related Topics