<if> Element Reference

The <if> element provides a way to conditionally included other elements based on an expression.

Attributes
NameFormatDescription
expr (required)Expression

Detail

The following example illustrates the conditional inclususion of a field:

    <?xml version="1.0" encoding="iso-8859-1" ?>
    <xddl>
     <structure>
      <field name="Included" length="8"/>
      <if expr="Included">
       <field name="More" length="8"/>
      </if>
     </structure>
    </xddl>

    simple_if.xddl

And here we parse two messages with the above file. The first one will include the More field and the second one will not:

    # idm simple_if.xddl 0105 00

    Name                           Length Value    Hex        Description 
    Included                       8      1        01         
    More                           8      5        05         

    Included                       8      0        00         

The expr attribute may be any XDDL expression. As long as it does not evaluate to zero, the conditional elements will be included.