SLAX Overview
Stylesheet Language Alternative Syntax (SLAX) is a language for writing Junos OS commit scripts, op scripts, and event scripts. It is an alternative to Extensible Stylesheet Language Transformations (XSLT). SLAX has a distinct syntax, but the same semantics as XSLT.
XSLT is a powerful and effective tool for handling Extensible Markup Language (XML) that works well for machine-to-machine communication, but its XML-based syntax is inconvenient for the development of complex programs.
SLAX has a simple syntax that follows the style of C and PERL. It provides a practical and succinct way to code, thus allowing you to create readable, maintainable commit, op, and event scripts. SLAX removes programming instructions and XPath expressions from XML elements. XML angle brackets and quotation marks are replaced by parentheses and curly brackets ({ }), which are the familiar delimiters of C and PERL.
The benefits of SLAX are particularly strong for programmers who are not already accustomed to XSLT, because SLAX allows them to concentrate on the new programming topics introduced by XSLT, rather than concentrating on learning a new syntax. For example, SLAX allows you to:
- Use if, else if, and else statements instead of <xsl:choose> and <xsl:if> elements
- Put test expressions in parentheses (( ))
- Use the double equal sign (==) to test equality instead of the single equal sign (=)
- Use curly braces to show containment instead of closing tags
- Perform concatenation using the underscore (_) operator, as in PERL, version 6
- Write text strings using simple quotation marks (" ") instead of the <xsl:text> element
- Define named templates with a syntax resembling a function definition
- Invoke named templates with a syntax resembling a function call
- Simplify namespace declarations
- Reduce the clutter in your scripts
- Write more readable scripts
For examples of commit and op scripts written in SLAX, see Commit Script Examples and Op Script Examples.
How SLAX Works
SLAX does not affect the expressiveness of XSLT; it only makes XSLT easier to use. The underlying SLAX constructs are completely native to XSLT. SLAX adds nothing to the XSLT engine. The SLAX parser parses an input document and builds an XML tree identical to the one produced when the XML parser reads an XSLT document.
SLAX functions as a preprocessor for XSLT. The Junos OS internally translates SLAX programming instructions (such as if, then, and else statements) into the equivalent XSLT instructions (such as <xsl:choose> and <xsl:if> elements). After this translation, the XSLT transformation engine—which, for the Junos OS, is the Junos OS management (mgd) process—is invoked.
Figure 2 shows the flow of SLAX script input and output.
Figure 2: SLAX Script Input and Output

Hide Navigation Pane
Show Navigation Pane
Download
SHA1