Hello DFDL community,
I am creating a DFDL schema for .exe files (Portable Executable file format).
At one point in the file are 2-bytes that represent sixteen 1-bit flags.
For each bit, if the bit = 1, then I want to output a message; otherwise output
0 (for now).
To test that I am correctly reading the 2 bytes I did this:
<xs:element name="Characteristics" type="xs:hexBinary" dfdl:length="2"
dfdl:lengthKind="explicit" dfdl:lengthUnits="bytes" />
The output contained the correct hex bytes:
07 01
To test that I am correctly consuming each individual bit I did this:
<xs:element name="Characteristic" type="unsignedint1" minOccurs="16"
maxOccurs="16" />
Here is the output:
<Characteristic>0</Characteristic>
<Characteristic>0</Characteristic>
<Characteristic>0</Characteristic>
<Characteristic>0</Characteristic>
<Characteristic>0</Characteristic>
<Characteristic>1</Characteristic>
<Characteristic>1</Characteristic>
<Characteristic>1</Characteristic>
<Characteristic>0</Characteristic>
<Characteristic>0</Characteristic>
<Characteristic>0</Characteristic>
<Characteristic>0</Characteristic>
<Characteristic>0</Characteristic>
<Characteristic>0</Characteristic>
<Characteristic>0</Characteristic>
<Characteristic>1</Characteristic>
You can see that those bits correspond to hex 07 01.
I want the value of each <Characteristic> element to be a message, not 0/1. So,
I used the dfdl:hiddenGroupRef approach to translate 0/1 to a message.
<xs:element name="Characteristics">
<xs:complexType>
<xs:sequence>
<xs:sequence
dfdl:hiddenGroupRef="hidden_characteristic_bit16_Group" />
<xs:element name="Characteristic-16" type="xs:string"
dfdl:inputValueCalc="{
if
(fn:lower-case(xs:string(../Hidden_characteristic_bit16)) eq "1") then "The
bytes of the word are reversed(obsolete)"
else xs:string(../Hidden_characteristic_bit16)}" />
<xs:sequence
dfdl:hiddenGroupRef="hidden_characteristic_bit15_Group" />
<xs:element name="Characteristic-15" type="xs:string"
dfdl:inputValueCalc="{
if
(fn:lower-case(xs:string(../Hidden_characteristic_bit15)) eq "1") then "The
image should only be run on a single processor computer"
else xs:string(../Hidden_characteristic_bit15)}" />
...
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:group name="hidden_characteristic_bit16_Group">
<xs:sequence>
<xs:element name="Hidden_characteristic_bit16" type="unsignedint1"
dfdl:outputValueCalc="{ . }" />
</xs:sequence>
</xs:group>
...
<xs:group name="hidden_characteristic_bit1_Group">
<xs:sequence>
<xs:element name="Hidden_characteristic_bit1" type="unsignedint1"
dfdl:outputValueCalc="{ . }" />
</xs:sequence>
</xs:group>
That produced this incorrect output:
<Characteristic-16>0</Characteristic-16>
<Characteristic-15>0</Characteristic-15>
<Characteristic-14>0</Characteristic-14>
<Characteristic-13>0</Characteristic-13>
<Characteristic-12>0</Characteristic-12>
<Characteristic-11>0</Characteristic-11>
<Characteristic-10>0</Characteristic-10>
<Characteristic-9>0</Characteristic-9>
<Characteristic-8>0</Characteristic-8>
<Characteristic-7>0</Characteristic-7>
<Characteristic-6>0</Characteristic-6>
<Characteristic-5>Aggressively trim the working set(obsolete)</Characteristic-5>
<Characteristic-4>0</Characteristic-4>
<Characteristic-3>0</Characteristic-3>
<Characteristic-2>0</Characteristic-2>
<Characteristic-1>0</Characteristic-1>
Is there a bug with hidden groups containing an element with a 1-bit value?
Note: here is how unsigned1 is defined:
<xs:simpleType name="unsignedint1" dfdl:length="1" dfdl:lengthKind="explicit"
dfdl:alignmentUnits="bits">
<xs:restriction base="xs:unsignedInt"/>
</xs:simpleType>
/Roger