Check that the fillbyte is %#×00;

The unused bits of your byte are filled from the fill byte when unparsing.

Get Outlook for Android<https://aka.ms/ghei36>

________________________________
From: Costello, Roger L. <[email protected]>
Sent: Monday, July 29, 2019 8:16:22 AM
To: [email protected] <[email protected]>
Subject: Unparsing a byte that is padded to byte boundary produces incorrect 
results

Hello DFDL community,

My input is binary. There is a 2-bit unsigned integer, followed by a 3-bit 
unsigned integer, and then it is padded to an 8-bit boundary. The bits are 
leastSignificantBitFirst. Here is my input (hex):

        0E

Here is my DFDL Schema:

<xs:element name="input">
    <xs:complexType>
        <xs:sequence>
            <xs:element name="two-bits" type="unsignedint2" />
            <xs:element name="three-bits" type="unsignedint3" />
            <xs:sequence dfdl:hiddenGroupRef="padToByteBoundary" />
        </xs:sequence>
    </xs:complexType>
</xs:element>

<xs:group name="padToByteBoundary">
    <xs:sequence dfdl:alignment="8" dfdl:alignmentUnits="bits"/>
</xs:group>

Parsing produces this XML:

<input>
  <two-bits>2</two-bits>
  <three-bits>3</three-bits>
</input>

Perfect!

However, unparsing produces incorrect binary (hex):

        CE

Yikes! What am I doing wrong, please?

/Roger

Reply via email to