Once declared, a script can use the variable to reference the represented value. When using variables their full case-sensitive name must be used, including the preceding dollar sign.

Sample script provided declares a variable of $router-name with a string value of "R1" assigned to it. Script then includes this variable as the content of <output> result tree element that writes "R1" to the console.

version 1.0;

ns junos = "http://xml.juniper.net/junos/*/junos";
ns xnm = "http://xml.juniper.net/xnm/1.1/xnm";
ns jcs = "http://xml.juniper.net/junos/commit-scripts/1.0";

import "../import/junos.xsl";

match / {
    <op-script-results> {
        var $router-name = "R1";
        <output> $router-name;
    }
}