Hello DFDL Community,

My input file contains a 32-bit field (bit 0 to bit 31). Bit 31 determines how 
to interpret the other bits: if bit 31 = 1 then bits 0 to 15 is an unsigned int 
denoting an ordinal number and the other bits must be zero. If bit 30 = 0 then 
bits 0 to 30 is an unsigned int denoting a hint/name table RVA. The following 
graphic illustrates the structure:

[cid:[email protected]]

How to express this in DFDL? I figured that I would create a hidden group that 
contains 32 1-bit elements. I would have a choice that expresses this: If 
hidden bit 31 = 1 then choose the ordinal_number element, otherwise (hidden bit 
31 = 0) choose hint_name_table_RVA element.

The value of ordinal_number is calculated by concatenating hidden bit 0 with 
hidden bit 1, ..., hidden bit 15. Then, cast that to unsigned int.

The value of hint_name_table_RVA is calculated by concatenating hidden bit 0 
with hidden bit 1, ..., hidden bit 30. Then, cast that to unsigned int.

You can see my schema below. Unfortunately, it fails. What is the right way to 
approach this problem, please?  /Roger

<xs:element name="Ordinal_Number" type="unsignedint16" dfdl:inputValueCalc="{
    unsignedint16(
    fn:concat(./Hidden_Lookup_Table_bit0,
    ./Hidden_Lookup_Table_bit1,
    ./Hidden_Lookup_Table_bit2,
    ./Hidden_Lookup_Table_bit3,
    ./Hidden_Lookup_Table_bit4,
    ./Hidden_Lookup_Table_bit5,
    ./Hidden_Lookup_Table_bit6,
    ./Hidden_Lookup_Table_bit7,
    ./Hidden_Lookup_Table_bit8,
    ./Hidden_Lookup_Table_bit9,
    ./Hidden_Lookup_Table_bit10,
    ./Hidden_Lookup_Table_bit11,
    ./Hidden_Lookup_Table_bit12,
    ./Hidden_Lookup_Table_bit13,
    ./Hidden_Lookup_Table_bit14,
    ./Hidden_Lookup_Table_bit15))
    }" />

<xs:element name="Hint_Name_Table_RVA" type="unsignedint31" 
dfdl:inputValueCalc="{
    unsignedint31(
    fn:concat(./Hidden_Lookup_Table_bit0,
    ./Hidden_Lookup_Table_bit1,
    ./Hidden_Lookup_Table_bit2,
    ./Hidden_Lookup_Table_bit3,
    ./Hidden_Lookup_Table_bit4,
    ./Hidden_Lookup_Table_bit5,
    ./Hidden_Lookup_Table_bit6,
    ./Hidden_Lookup_Table_bit7,
    ./Hidden_Lookup_Table_bit8,
    ./Hidden_Lookup_Table_bit9,
    ./Hidden_Lookup_Table_bit10,
    ./Hidden_Lookup_Table_bit11,
    ./Hidden_Lookup_Table_bit12,
    ./Hidden_Lookup_Table_bit13,
    ./Hidden_Lookup_Table_bit14,
    ./Hidden_Lookup_Table_bit15,
    ./Hidden_Lookup_Table_bit16,
    ./Hidden_Lookup_Table_bit17,
    ./Hidden_Lookup_Table_bit18,
    ./Hidden_Lookup_Table_bit19,
    ./Hidden_Lookup_Table_bit20,
    ./Hidden_Lookup_Table_bit21,
    ./Hidden_Lookup_Table_bit22,
    ./Hidden_Lookup_Table_bit23,
    ./Hidden_Lookup_Table_bit24,
    ./Hidden_Lookup_Table_bit25,
    ./Hidden_Lookup_Table_bit26,
    ./Hidden_Lookup_Table_bit27,
    ./Hidden_Lookup_Table_bit28,
    ./Hidden_Lookup_Table_bit29,
    ./Hidden_Lookup_Table_bit30
    ))
    }" />

<xs:group name="hidden_Lookup_Table_Group">
    <xs:sequence dfdl:alignmentUnits="bits">
        <xs:element name="Hidden_Lookup_Table_bit7" type="unsignedint1"
            dfdl:outputValueCalc='{ . }'
        />
        <xs:element name="Hidden_Lookup_Table_bit6" type="unsignedint1"
            dfdl:outputValueCalc='{ . }'
        />
        <xs:element name="Hidden_Lookup_Table_bit5" type="unsignedint1"
            dfdl:outputValueCalc='{ . }'
        />
        <xs:element name="Hidden_Lookup_Table_bit4" type="unsignedint1"
            dfdl:outputValueCalc='{ . }'
        />
        <xs:element name="Hidden_Lookup_Table_bit3" type="unsignedint1"
            dfdl:outputValueCalc='{ . }'
        />
        <xs:element name="Hidden_Lookup_Table_bit2" type="unsignedint1"
            dfdl:outputValueCalc='{ . }'
        />
        <xs:element name="Hidden_Lookup_Table_bit1" type="unsignedint1"
            dfdl:outputValueCalc='{ . }'
        />
        <xs:element name="Hidden_Lookup_Table_bit0" type="unsignedint1"
            dfdl:outputValueCalc='{ . }'
        />
        <xs:element name="Hidden_Lookup_Table_bit15" type="unsignedint1"
            dfdl:outputValueCalc='{ . }'
        />
        <xs:element name="Hidden_Lookup_Table_bit14" type="unsignedint1"
            dfdl:outputValueCalc='{ . }'
        />
        <xs:element name="Hidden_Lookup_Table_bit13" type="unsignedint1"
            dfdl:outputValueCalc='{ . }'
        />
        <xs:element name="Hidden_Lookup_Table_bit12" type="unsignedint1"
            dfdl:outputValueCalc='{ . }'
        />
        <xs:element name="Hidden_Lookup_Table_bit11" type="unsignedint1"
            dfdl:outputValueCalc='{ . }'
        />
        <xs:element name="Hidden_Lookup_Table_bit10" type="unsignedint1"
            dfdl:outputValueCalc='{ . }'
        />
        <xs:element name="Hidden_Lookup_Table_bit9" type="unsignedint1"
            dfdl:outputValueCalc='{ . }'
        />
        <xs:element name="Hidden_Lookup_Table_bit8" type="unsignedint1"
            dfdl:outputValueCalc='{ . }'
        />
        <xs:element name="Hidden_Lookup_Table_bit23" type="unsignedint1"
            dfdl:outputValueCalc='{ . }'
        />
        <xs:element name="Hidden_Lookup_Table_bit22" type="unsignedint1"
            dfdl:outputValueCalc='{ . }'
        />
        <xs:element name="Hidden_Lookup_Table_bit21" type="unsignedint1"
            dfdl:outputValueCalc='{ . }'
        />
        <xs:element name="Hidden_Lookup_Table_bit20" type="unsignedint1"
            dfdl:outputValueCalc='{ . }'
        />
        <xs:element name="Hidden_Lookup_Table_bit19" type="unsignedint1"
            dfdl:outputValueCalc='{ . }'
        />
        <xs:element name="Hidden_Lookup_Table_bit18" type="unsignedint1"
            dfdl:outputValueCalc='{ . }'
        />
        <xs:element name="Hidden_Lookup_Table_bit17" type="unsignedint1"
            dfdl:outputValueCalc='{ . }'
        />
        <xs:element name="Hidden_Lookup_Table_bit16" type="unsignedint1"
            dfdl:outputValueCalc='{ . }'
        />
        <xs:element name="Hidden_Lookup_Table_bit31" type="unsignedint1"
            dfdl:outputValueCalc='{ . }'
        />
        <xs:element name="Hidden_Lookup_Table_bit30" type="unsignedint1"
            dfdl:outputValueCalc='{ . }'
        />
        <xs:element name="Hidden_Lookup_Table_bit29" type="unsignedint1"
            dfdl:outputValueCalc='{ . }'
        />
        <xs:element name="Hidden_Lookup_Table_bit28" type="unsignedint1"
            dfdl:outputValueCalc='{ . }'
        />
        <xs:element name="Hidden_Lookup_Table_bit27" type="unsignedint1"
            dfdl:outputValueCalc='{ . }'
        />
        <xs:element name="Hidden_Lookup_Table_bit26" type="unsignedint1"
            dfdl:outputValueCalc='{ . }'
        />
        <xs:element name="Hidden_Lookup_Table_bit25" type="unsignedint1"
            dfdl:outputValueCalc='{ . }'
        />
        <xs:element name="Hidden_Lookup_Table_bit24" type="unsignedint1"
            dfdl:outputValueCalc='{ . }'
        />
    </xs:sequence>
</xs:group>




Reply via email to