[DFDL-WG] How do I preserve order in an unordered list?

Garriss Jr., James P. jgarriss at mitre.org
Tue Oct 8 10:21:41 EDT 2013


(Sent on behalf of Roger Costello)

Hi Folks,

I am trying out the sequenceKind="unordered" property.

I created this simple test:

    <xs:element name="Test">
        <xs:complexType>
            <xs:sequence dfdl:sequenceKind="unordered" dfdl:separator="%SP;">
                <xs:element name="A" type="xs:string" dfdl:initiator="A:" />
                <xs:element name="B" type="xs:string" dfdl:initiator="B:" />
            </xs:sequence>
        </xs:complexType>
    </xs:element>

That schema says the input data must consist of A:___ and B:___, in any order.

Here is sample input:

   B:Cat A:Dog

I processed the input using the schema and here is the result that I got from Daffodil:

    <Test>
        <A>Dog</A>
        <B>Cat</B>
    </Test>

Notice that the order of the input data changed in the result XML. This was quite surprising to me.

Upon consulting the DFDL specification, it appears that the exhibited behavior is expected:

            ... a DFDL processor must sort the members of an
            unordered group into schema order when parsing.

QUESTIONS:

1. Is this really the desired behavior? I would not expect parsing to alter the order of any data. From my XML Schema experience, I would be shocked if an XML Schema validator altered the order of markup in XML instances simply because the XML Schema specified <all> (unordered sequence).

2. If we grant that this really is the desired behavior, then how do I create an unordered sequence in which DFDL parsing preserves the order of the data? In the above example, if the input data lists B:Cat first and A:Dog second, then how do I get that order preserved in the result XML?

/Roger
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.ogf.org/pipermail/dfdl-wg/attachments/20131008/cf954035/attachment.html>


More information about the dfdl-wg mailing list