You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@daffodil.apache.org by "Costello, Roger L." <co...@mitre.org> on 2019/07/29 12:16:22 UTC
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
Re: Unparsing a byte that is padded to byte boundary produces
incorrect results
Posted by "Beckerle, Mike" <mb...@tresys.com>.
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. <co...@mitre.org>
Sent: Monday, July 29, 2019 8:16:22 AM
To: users@daffodil.apache.org <us...@daffodil.apache.org>
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