Cernunnos Manual


<choose>

Description:

Performs the subtasks within the first WHEN element (<when>) whose 'test' attribute returns true. You may optionally provide an OTHERWISE (<otherwise>) element whose subtasks will be performed if none of the WHEN conditions are met.

Reagents:

Name XPath Description Reagent Type Expected Type Required
WHEN when Zero or more child <when> elements each containing a 'test' attribute. The SUBTASKS of the first WHEN whose test is positive (true) will be performed. NODE_LIST java.util.List No
OTHERWISE otherwise Optional <otherwise> element whose children will be performed if none of the specified WHEN conditions is met. NODE_LIST java.util.List No

Examples:

Invokes 'is-admin.crn' to deturmine if the user is an administrator, then either (1) deletes the file(s) specified on the command prompt or (2) gives the user appropriate feedback:

 
       
        <choose> 
          <when test="${crn(is-admin.crn)}"> 
            <argument-iterator> 
              <delete-file file="${Attributes.STRING}"/> 
            </argument-iterator> 
          </when>  
          <otherwise> 
            <echo-ln>You are not authorized to perform the specified action.</echo-ln> 
          </otherwise> 
        </choose>