<range> Element Reference

The <range> element only appears as a child of the <enum> element. It is used to specify a range for an enumerated list.

Attributes
NameFormatDescription
end (required)int
start (required)int
valuestring

Detail

The following example maps a value into a temperature range for each part of the day.

    # idm temperature.xddl 30526044

     xo read file error: -2

Providing Default Values

%range and <item> elements can both exist in the same <enum>. The <item> values are evaluated first, and the <range> second. This means a <range> can overlap existing items. Using these two mechanics, we can use a <range> as a default if no items match a particular value.

The following example illustrates this. The first part of the enum lists several colors with their RGB Hex Triplet. The <range> at the bottom will be used if no <item> matches.

    <?xml version="1.0" encoding="iso-8859-1" ?>
    <xddl>
     <type id="colors">
      <enum>
        <!-- A -->
        <item key="#F0F8FF" value="Alice blue"/>
        <item key="#E32636" value="Alizarin"/>
        <item key="#E52B50" value="Amaranth"/>
        <item key="#FFBF00" value="Amber"/>
        <item key="#9966CC" value="Amethyst"/>
        <item key="#FBCEB1" value="Apricot"/>
        <item key="#00FFFF" value="Aqua"/>
        <item key="#7FFFD4" value="Aquamarine"/>
        <item key="#4B5320" value="Army green"/>
        <item key="#7BA05B" value="Asparagus"/>
        <item key="#FF9966" value="Atomic tangerine"/>
        <item key="#6D351A" value="Auburn"/>
        <item key="#007FFF" value="Azure (color wheel)"/>
        <item key="#F0FFFF" value="Azure (web)"/>

        <range start="0" end="#FFFFFF" value="Unknown Color"/>
      </enum>
     </type>
      <structure>
        <field length="24" name="first" type="#colors"/>
        <field length="24" name="second" type="#colors"/>
        <field length="24" name="third" type="#colors"/>
        <field length="24" name="fourth" type="#colors"/>
        <field length="24" name="fifth" type="#colors"/>
        <field length="24" name="sixth" type="#colors"/>
        <field length="24" name="seventh" type="#colors"/>
        <field length="24" name="eighth" type="#colors"/>
        <field length="24" name="ninth" type="#colors"/>
      </structure>
    </xddl>

    range.xddl

Parsing a message with this file yields:

    # idm range.xddl E3263600FFFF0000FFF0FFFF66FF00ACE1AF4B5320FF9966F19CBB

    Name                           Length Value    Hex        Description 
    first                          24     14886454 E32636     Alizarin
    second                         24     65535    00FFFF     Aqua
    third                          24     255      0000FF     Unknown Color
    fourth                         24     15794175 F0FFFF     Azure (web)
    fifth                          24     6749952  66FF00     Unknown Color
    sixth                          24     11329967 ACE1AF     Unknown Color
    seventh                        24     4936480  4B5320     Army green
    eighth                         24     16750950 FF9966     Atomic tangerine
    ninth                          24     15834299 F19CBB     Unknown Color

See the <type> element reference for more usage of types.