XMLMath
XMLMath
 
Font size:      

Example: Conditional Evaluation

If-Then-Else

This example serves to illustrate the use of conditional evaluation in xmlmath. Using the <choose> operator, one of two possible branches of the expression tree is selected. It evaluates to the string "foo".

							
<expression xmlns="http://xmlmath.org/1.0">
  <choose>
    <if>
      <true/>
    </if>
    <then>
      <string value="foo"/>
    </then>
    <else>
      <string value="bar"/>
    </else>
  </choose>
</expression>
						

For brevity, it is allowed to omit the <if>, <then> and <else> tags. This is illustrated in the expression below, which is semantically equivalent to the previous.

							
<expression xmlns="http://xmlmath.org/1.0">
  <choose>
    <true/>
    <string value="foo"/>
    <string value="bar"/>
  </choose>
</expression>