I assume the goal is for your data to be byte-aligned? If so, you could use an 
empty sequence with the alignment attributes set.


If that is not possible, then you need some way to determine at unparse time 
how many bits of padding you need. If you have that, then you can create a 
single hidden element, and set the dfdl:length field to an expression 
indicating how many bits of padding you require.

________________________________
From: Costello, Roger L. <coste...@mitre.org>
Sent: Tuesday, July 23, 2019 1:39:58 PM
To: users@daffodil.apache.org <users@daffodil.apache.org>
Subject: How to create a hidden group for 0-7 padding bits?

Hello DFDL community,

I swore that I would not use hidden groups, but I just can't bear to display 
padding bits in the XML output.

My input file is binary. At the end of a section, there may be 0-7 padding 
bits. The following doesn't work because outputValueCalc is not allowed on an 
array:

<xs:group name="padding7Bits">
    <xs:sequence>
        <xs:element name="padding" minOccurs="0" maxOccurs="7"
                dfdl:occursCountKind="implicit" type="unsignedint1"
                 dfdl:outputValueCalc="{0}" />
    </xs:sequence>
</xs:group>

Next, this doesn't work because outputValueCalc is not allowed on optional 
elements:

<xs:group name="padding7Bits">
    <xs:sequence>
        <xs:element name="bit0" minOccurs="0" dfdl:occursCountKind="implicit"
                type="unsignedint1" dfdl:outputValueCalc="{0}" />
        <xs:element name="bit1" minOccurs="0" dfdl:occursCountKind="implicit"
                 type="unsignedint1" dfdl:outputValueCalc="{0}" />
        <xs:element name="bit2" minOccurs="0" dfdl:occursCountKind="implicit"
                 type="unsignedint1" dfdl:outputValueCalc="{0}" />
        <xs:element name="bit3" minOccurs="0" dfdl:occursCountKind="implicit"
                 type="unsignedint1" dfdl:outputValueCalc="{0}" />
        <xs:element name="bit4" minOccurs="0" dfdl:occursCountKind="implicit"
                 type="unsignedint1" dfdl:outputValueCalc="{0}" />
        <xs:element name="bit5" minOccurs="0" dfdl:occursCountKind="implicit"
                 type="unsignedint1" dfdl:outputValueCalc="{0}" />
        <xs:element name="bit6" minOccurs="0" dfdl:occursCountKind="implicit"
                 type="unsignedint1" dfdl:outputValueCalc="{0}" />
    </xs:sequence>
</xs:group>

So, how do I declare the hidden group?

/Roger

Reply via email to