npsobj_switch ::= <npsobj switch = "switchName"> { <npsobj casecond = "caseCondition" [ negate = "" ] [ proceed = ( "yes" | "no" ) ] ( name = "caseName" | value = "caseValue" )> content </npsobj> } [ <npsobj casecond = "default" [ proceed = ("yes" | "no" ) ] > content </npsobj> ] </npsobj>
This element lets you compare a value (switchName
) available in the current context to several other values (caseName
) or constants (caseValue
). For every comparison, one of the comparison operators (caseCondition
) also available for npsobj_condition
can be used. If a unary comparison operator (such as isEmpty
) is applied to switchName
, caseName
and caseValue
are ignored. Otherwise switchName
is compared to either caseName
or caseValue
, depending on whether name
or value
has been specified. If a condition applies, the content
of the caseCond
element concerned is evaluated.
For switchName
and caseName
any name available in the current context can be used. To compare switchName
to a string constant, use caseValue
. By means of the optional negate
attribute, the result of the comparison operation can be reversed. If caseCondition
is no comparison operator but default
instead, the comparison always applies. In a switch
instruction, default
is typically the last comparison. This makes it possible to handle the case that none of the preceding comparisons applied.
By means of the optional proceed
attribute you can control whether the next casecond
instruction in the switch
block is to be processed even if the condition applies (default: no
).
Inside a switch
element only casecond
elements are evaluated. Text as well as other elements on the same level are ignored.
<npsobj switch="name"> <npsobj casecond="isEqual" value="news1"> News folder 1 </npsobj> <npsobj casecond="isEqual" value="news2"> News folder 2 </npsobj> <npsobj casecond="default"> No news folder </npsobj> </npsobj>