[j-nsp] predicates in if statement expression in SLAX

Phil Shafer phil at juniper.net
Wed Mar 14 16:52:40 EDT 2018


Martin T writes:
>Is there a difference between following two if statement expressions:
>if ($node-set/foo/bar == "klm") {
>..and:
>if ($node-set[foo/bar == "klm"]) {

If there is, I'm missing it.

The first expression selects a set of "bar" nodes and then returns
true if any of them are "klm".  The second selects a set of first-level
nodes under $node-set named "foo" with a "bar" child that equals
"klm".  While the two expressions build different types (boolean
.vs. node-set), the resulting booleans should be equivalent: either
way the result will be false if $node-set contains no "foo" nodes
which contain "bar" children that equal "klm".

Thanks,
 Phil


More information about the juniper-nsp mailing list