There are five data types defined in the SLAX scripting language:

  • string: a sequence of text characters, for example "Hello World!"
  • number: numbers are stored as floating points so decimals are permitted
  • boolean: used for conditional operations; evaluated as either true or false
  • result tree fragment: a portion of the result tree. By default, all XML elements that are embedded in a script are written to the result tree. It is possible, however, to redirect this XML data to a variable instead. The variable stores the data as an unparsed XML data structure, as such no additional data can be extracted from it. The script can only use the unparsed data to write to the result tree later or convert to a node-set or a string.
  • node-set: an ordered set of XML nodes. A node-set consists of parsed XML data, so information can be extracted from it. Typically, node-sets are the result of a query to Junos for information, a location path, or a converted result tree fragment.

version 1.0;

ns junos = "*/junos";
ns xnm = "";
ns jcs = "";

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

/* This is a Global Variable */
var $first-string = "Hello World!";

match / {
    <op-script-results> {
        /* This is a variable with template scope */
        var $second-string = "Goodbye World!";
        /* Output both variables to the console */
        <output> $first-string;
        <output> $second-string;