Wiki source for HowToXMLCondition
======How To use an XML Expression as a condition======
XML expressions can be used in conditionals in several ways. The most direct way is a boolean xml expression using the test command.
====Using the test command====
XML Expressions used in the test command are evaluated in boolean context. For example, this (admitedly verbose syntax) expression tests the xml true expression. When an XML expression is used as the sole argument to the test command ("[ expr ]") it is converted to a boolean value following the xpath rules.
%%
[ <[ fn:true() ]> ] && Echo Is True
%%
A more useful example tests if a sequence is the empty sequence.
%%
foo=(a sequence)
[ <[ $foo ]> ] && echo foo is not the empty sequence
foo=()
[ <[ $foo ]> ] || echo foo is the empty sequence
%%
----
[[HowTo]]
[[CategoryHowTo]]
XML expressions can be used in conditionals in several ways. The most direct way is a boolean xml expression using the test command.
====Using the test command====
XML Expressions used in the test command are evaluated in boolean context. For example, this (admitedly verbose syntax) expression tests the xml true expression. When an XML expression is used as the sole argument to the test command ("[ expr ]") it is converted to a boolean value following the xpath rules.
%%
[ <[ fn:true() ]> ] && Echo Is True
%%
A more useful example tests if a sequence is the empty sequence.
%%
foo=(a sequence)
[ <[ $foo ]> ] && echo foo is not the empty sequence
foo=()
[ <[ $foo ]> ] || echo foo is the empty sequence
%%
----
[[HowTo]]
[[CategoryHowTo]]