libslax Distribution Overview
Stylesheet Language Alternative syntaX (SLAX) is an alternative syntax for XSLT. SLAX is tailored for readability and familiarity, following the style of C and Perl. The SLAX language moves programming constructs and XPath expressions from the XML elements and attributes used in XSLT to first class language constructs. SLAX was originally developed as part of Junos OS for the purpose of on-box scripting to enable you to customize and enhance the CLI.
libslax is an open-source implementation of the SLAX language using the "New BSD License". libslax is written in C and is built on top of the libxml2, libxslt, and libexslt libraries. The libslax distribution includes the libslax library, which incorporates a SLAX parser and SLAX writer, the SLAX processor (slaxproc), a debugger, and a profiler. Table 1 describes the components of the libslax distribution.
| libslax Tool | Description |
|---|---|
|
SLAX debugger (sdb) |
A debugger that resembles |
|
SLAX parser |
Tool that reads SLAX files, turning the SLAX source file into an XSLT tree (xmlDocPtr). |
|
SLAX processor (slaxproc) |
Command-line tool that can format SLAX scripts, validate SLAX script syntax, run and debug SLAX scripts, and convert between SLAX and XSLT formats. |
|
SLAX profiler |
A SLAX debugger tool that reports information about the activity and performance of a script. |
|
SLAX writer |
Tool that writes SLAX files, turning an XSLT tree (xmlDocPtr) into a file containing SLAX statements. |
|
|
Command that enables the printing of informational data when levels of the script are entered and exited. |
You can download and install the libslax distribution on a computer with a UNIX-like OS to develop SLAX scripts outside of Junos OS. The standard Junos OS and Junos OS Evolved software also includes the libslax tools. Table 2 outlines the libslax version and corresponding SLAX version included with each release.
|
Junos OS or Junos OS Evolved Release |
libslax Version |
SLAX Version |
|---|---|---|
|
14.1 |
0.14.1 |
1.1 |
|
14.2 through 17.3 |
0.17.1 |
1.2 |
|
17.4 through 25.2 19.2-EVO through 25.2-EVO |
0.22.0 |
1.2 |
|
25.4R1 and later 25.4R1-EVO and later |
3.1.6 | 1.3 |
The libslax 3.1.6 update (SLAX version 1.3) includes the following enhancements:
-
SLAX processor updates:
-
New SLAX processor mode:
xml-to-yaml -
New SLAX processor options:
indent-width,json,profile,profile-mode,version-only, andwidth -
Improved SLAX processor Argument Handling
-
-
libslax extension library updates:
-
New
bitlibrary functions:shift-left(),shift-right(), andashift-right() -
New
xutillibrary functions:common(),distinct(),slax-to-xml(), andxml-to-slax()
-
-
SLAX script enhancements:
-
New SLAX extension functions:
ends-with(),get-host(), andjoin(). -
Enhanced SLAX function:
printf() -
Enhanced SLAX statement:
output-method -
Support for syntax with optional parentheses for SLAX statements:
else if,for,for-each,if, andwhile -
Support for hexadecimal numbers in SLAX scripts
-
For more information about libslax, including source code, release notes, additional documentation, and support materials, see the following sites: