Combined Comparisons

If, depending on the value of a field, many different texts are to be output, it is convenient to use a switch instruction instead of many condition instructions. With switch, field values can be compared more efficiently and if-then-else structures can be used in layouts. This is shown in the following example:

<npsobj switch="objClass">
  <npsobj casecond="isEqual" value="newspub">
    <npsobj insertvalue="template" name="newsnav" />
  </npsobj>
  <npsobj casecond="isEqual" value="archivepub">
    <npsobj insertvalue="template" name="archivenav" />
  </npsobj>
  <npsobj casecond="isEqual" value="productpub">
    <npsobj insertvalue="template" name="productnav" />
  </npsobj>
  <npsobj casecond="default">
    <npsobj insertvalue="template" name="standardnav" />
  </npsobj>
</npsobj>

One after the other, this code compares the objClass field with the character strings newspub, archivepub, and productpub. If the value of objClass equals one of these character strings, a corresponding navigation layout is included, and the rest of the switch instruction is skipped. If objClass matches none of these values, then the casecond-default instruction is processed because this condition is always satisfied.

The proceed tag attribute in the NPSOBJ casecond tag with its permitted values yes and no lets you control whether the next casecond instruction in the switch instruction is to be processed even if the condition is satisfied. This is by default not the case, i. e. the value of proceed is no, if this tag attribute has not been specified. This has the effect that the rest of the switch instruction is ignored.