[j-nsp] negation operator in SLAX

Phil Shafer phil at juniper.net
Mon Jun 18 14:40:23 EDT 2018

Martin T writes:
>Oh, yes. I forgot the not() function. I made a small comparison
>between not(), jcs:empty() and ! using five data types in SLAX:

"!" and "not" are identical.  The "!" is just syntactic sugar that
turns "! x " into "not(x)", as you can see in the code:


>5) Empty RTF:
>"not( $rtf )" returns false, which is an expected result because even
>an empty RTF converts to true. "jcs:empty( $rtf )", to my surprise,
>returns true. According to documentation, RTF is always considered to
>not be empty. "! $rtf" returns false.

RTFs are exactl the reason I made jcs:empty(), since it bugs me
that boolean($rtf) is true.


And "bugs" is too weak a word.  Imho, RTFs are the chief source of
slax/xslt violations of the Principal of Least Astonishment.

    % cat /tmp/foo.slax
    version 1.2;

    var $a := <a> {
      <b> "b";

    main <top> {
        var $x = { copy-of $a/z; }
        var $y = $a/z;

        <x> boolean($x);
        <y> boolean($y);
    % slaxproc -g -E /tmp/foo.slax
    <?xml version="1.0"?>

See also the ":=" assignment operator, which helps avoid RTFs:



More information about the juniper-nsp mailing list