Blog Viewer

Scripting How-To: Tracking the Failure or Success of a SLAX Script with Variables

By Erdem posted 03-30-2016 14:20


To track the failure or success of a SLAX script, you typically look through several blocks of XML. If a certain value exists in one of more of the blocks, run a "success" block of code; otherwise, run a "failure" block of code. This would be trivial if the SLAX script had variables that you could modify, but it does not. So one solution is to feed back XML data into a variable while you process the XML document, and then check that variable afterward.


For example:


var $catch-results := {
    for-each( $configuration/interfaces/interface ) {
        if( mtu == "1500" ) {
            <error> "Bad MTU";
        else {
if( $catch-results/error ) {
    expr jcs:output( "There was an error");