Skip to main content
Previous sectionNext section

DTL <switch>

Evaluate <case> elements and execute the contents of the first one that evaluates to true.

Syntax

<switch>
   <case condition="1">
   ...
   </case>
   <default>
   ...
   </default> 
</switch>
Copy code to clipboard

Attributes

None.

Elements

Element Purpose
<annotation> Optional. A text string that describes the <switch> element.
<case> The first <case> element that evaluates to true is executed.
<default> Optional. If none of the <case> elements evaluate to true, the contents of the <default> element are executed.

Description

The <switch> element contains one or more <case> elements along with an optional <default> element. The contents of a <case> element are executed if the condition evaluates to true. Once a <case> element evaluates to true, none of the other <case> elements nor the <default> element are evaluated. The contents of the <default> element are executed if none of the <case> elements evaluate to true.