<pad> Element Reference

The <pad> element is used to align a record to a boundary. Typically, this will be a byte boundary, but can be changed by using the attributes.

It's length is not determined by a fixed value or expression, rather it is determined by the current bit number of the message or record it appears in.

Attributes
NameFormatDescription
modintThe modulus used in padding, specified as a number of bits. The default is 8.
namestringThe name of the pad. The default is "pad".
Children<comment>?

? = 0 or 1 occurence, * = 0 or more occurences

Detail

Without attributes specified, the <pad> element will consume bits of the record until the record is byte aligned. For example, the <pad> element in following document will consume 3 bits in order to make the message byte aligned.

    <?xml version="1.0" encoding="iso-8859-1" ?>
    <xddl>
     <structure>
      <field name="A" length="5"/>
      <pad/>
      <field name="B" length="8"/>
     </structure>
    </xddl>

    pad.xddl

    # idm pad.xddl A014

    Name                           Length Value    Hex        Description 
    A                              5      20       14         
    pad                            3      0        00         
    B                              8      20       14         

As we can see, the length of the pad is 3.

If we change the length of the A field to 2, we get a pad of 6, as expected:

    <?xml version="1.0" encoding="iso-8859-1" ?>
    <xddl>
     <structure>
      <field name="A" length="2"/>
      <pad/>
      <field name="B" length="8"/>
     </structure>
    </xddl>

    pad1.xddl

    # idm pad1.xddl A014

    Name                           Length Value    Hex        Description 
    A                              2      2        02         
    pad                            6      32       20         
    B                              8      20       14         

mod

The mod attribute is used to further modify the behavior. For example, it may be desireable to pad to the nearest 2-byte boundary, in which case we would specify a pad of 16.