Hello DFDL community,

My input contains 8 bytes. If the first 4 bytes are all zeroes, then the 
remaining four bytes represent an offset. Otherwise, the 8 bytes represent a 
null-terminated string. For example, if the input is this:

2E 64 61 74 61 00 00 00

Then the XML output should be this:

<Name>.data</Name>

If the input is this:

00 00 00 00 12 34 56 78

Then the XML output should be this:

<Offset>12345678</Offset>

I have no idea how to write a DFDL schema for this input. Below is my attempt, 
but it just produces "An unexpected exception occurred. This is a bug" message.

Would you give some guidance on how to create a DFDL schema for the input, 
please?  /Roger

<xs:element name="Symbol_Name">
    <xs:complexType>
        <xs:sequence>
            <xs:sequence dfdl:hiddenGroupRef="hidden_hexBinary8_Group" />
            <xs:choice>
                <xs:sequence>
                    <xs:annotation>
                        <xs:appinfo source="http://www.ogf.org/dfdl/";>
                            <dfdl:discriminator test="{xs:string(Hidden_byte1) 
eq '00' and
                                xs:string(Hidden_byte2) eq '00' and
                                xs:string(Hidden_byte3) eq '00' and
                                xs:string(Hidden_byte4) eq '00'}" />
                        </xs:appinfo>
                    </xs:annotation>
                    <xs:element name="Offset" type="xs:hexBinary" 
dfdl:inputValueCalc="{
                        fn:concat(xs:string(../Hidden_byte8),
                        xs:string(../Hidden_byte7),
                        xs:string(../Hidden_byte6),
                        xs:string(../Hidden_byte5))}"
                    />
                </xs:sequence>
                <xs:sequence>
                    <xs:annotation>
                        <xs:appinfo source="http://www.ogf.org/dfdl/";>
                            <dfdl:discriminator test="{xs:string(Hidden_byte1) 
ne '00'}" />
                        </xs:appinfo>
                    </xs:annotation>
                    <xs:element name="Name" type="xs:string" 
dfdl:representation="text"
                        dfdl:encoding="ISO-8859-1" dfdl:inputValueCalc="{
                        fn:concat(xs:string(../Hidden_byte1),
                        xs:string(../Hidden_byte2),
                        xs:string(../Hidden_byte3),
                        xs:string(../Hidden_byte4),
                        xs:string(../Hidden_byte5),
                        xs:string(../Hidden_byte6),
                        xs:string(../Hidden_byte7),
                        xs:string(../Hidden_byte8))}"
                    />
                </xs:sequence>
            </xs:choice>
        </xs:sequence>
    </xs:complexType>
</xs:element>


<xs:group name="hidden_hexBinary8_Group">
    <xs:sequence>
        <xs:element name="Hidden_byte1" type="hexBinary1" 
dfdl:outputValueCalc='{ . }' />
        <xs:element name="Hidden_byte2" type="hexBinary1" 
dfdl:outputValueCalc='{ . }' />
        <xs:element name="Hidden_byte3" type="hexBinary1" 
dfdl:outputValueCalc='{ . }' />
        <xs:element name="Hidden_byte4" type="hexBinary1" 
dfdl:outputValueCalc='{ . }' />
        <xs:element name="Hidden_byte5" type="hexBinary1" 
dfdl:outputValueCalc='{ . }' />
        <xs:element name="Hidden_byte6" type="hexBinary1" 
dfdl:outputValueCalc='{ . }' />
        <xs:element name="Hidden_byte7" type="hexBinary1" 
dfdl:outputValueCalc='{ . }' />
        <xs:element name="Hidden_byte8" type="hexBinary1" 
dfdl:outputValueCalc='{ . }' />
    </xs:sequence>
</xs:group>


<xs:simpleType name="hexBinary1" dfdl:length="1" dfdl:lengthKind="explicit" 
dfdl:lengthUnits="bytes">
    <xs:restriction base="xs:hexBinary"/>
</xs:simpleType>

Reply via email to