Help us improve your experience.

Let us know what you think.

Do you have time for a two-minute survey?

 
 

Convert Scripts Between SLAX and XSLT

Convert a complete or partial script written in SLAX or XSLT into the alternate language.

You can write Junos automation scripts in SLAX and XSLT. SLAX is a C-like alternative syntax to XSLT. You can view SLAX as a preprocessor for XSLT. Before Junos OS invokes the XSLT processor, the software converts any SLAX constructs in the script (such as if/else if/else) to equivalent XSLT constructs (such as <xsl:choose> and <xsl:if>). For more information about SLAX, see SLAX Overview.

You can use the request system scripts convert operational mode command to convert a complete or partial script written in SLAX or XSLT into the alternate language. Users familiar with C and PERL can convert existing XSLT scripts to SLAX to more easily read and maintain the scripts. In addition, converting a script and studying the results facilitates learning the differences between the two languages.

The following sections explain how to convert a script from one language to the other.

Convert a Script from SLAX to XSLT

To convert a SLAX script to XSLT, issue the request system scripts convert slax-to-xslt operational mode command. Specify the source file, the destination directory, and optionally, a destination file. You can include the partial option to convert a partial script. The source script is the basis for the new script and is not overwritten in the conversion process.

The command syntax is:

The following examples convert a script from SLAX to XSLT using a source and destination directory relevant to the default storage location for that script type:

When you issue the previous slax-to-xslt conversion command, the script1.slax file remains unchanged in the source directory, and a new script called script1.xsl is added to the destination directory.

If you specify only the destination directory, and you do not specify a destination filename, the device generates a filename. The generated filename is slax-temp or SLAX-Conversion-Temp, depending on the Junos OS release, and a randomly generated, five-character, alpha-numeric extension.

Convert a Script from XSLT to SLAX

To convert an XSLT script to SLAX, issue the request system scripts convert xslt-to-slax operational mode command. Specify the source file, the destination directory, and optionally, a destination file. The source script is the basis for the new script and is not overwritten in the conversion process.

The command syntax is:

To convert a partial script, include the partial option in the command. The version option specifies the SLAX version that the generated script lists in its version statement.

The following examples convert a script from XSLT to SLAX using a source and destination directory relevant to the default storage location for that script type:

When you issue the previous xslt-to-slax conversion command, the script1.xsl file remains unchanged in the source directory, and a new script called script1.slax is added to the destination directory.

The SLAX script boilerplate lists the specified SLAX version. In this example, the version is 1.2. If you do not specify a version, the version defaults to the latest SLAX version available on the device.

If you specify only the destination directory, and you do not specify a destination filename, the device generates a filename. The generated filename is slax-temp or SLAX-Conversion-Temp, depending on the Junos OS release, and a randomly generated, five-character, alpha-numeric extension.