I realize the prior answers didn't really answer your question.

When I have an explicit number of padding bits to absorb/generate, but I need 
to capture/preserve their values, I use:


<xs:element name="pad3" type="xs:unsignedInt"

   dfdl:lengthKind="explicit" dfdl:length="3" dfdl:lengthUnits="bits"/>

(assumes representation="binary" alignment="1" alignmentUnits="bits")

You can add dfdl:outputValueCalc="{ 0 }" if you want the 3 bits initialized on 
output, instead of preserving existing contents. Zeroing out the bits will 
invalidate things like checksums potentially if the bits weren't all zero 
initially.
________________________________
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