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

Mike Beckerle mbeckerle.dfdl at gmail.com
Tue Oct 8 11:05:37 EDT 2013


Yes, the behavior is entirely intentional.

Erase the DFDL annotation: now your model has a <sequence> containing first
element A, then element B. If we allowed those to be in the other order
your infoset would not be valid for your model.

If you want to preserve the order information you need to model that
differently. Perhaps via an array with a element containing a choice inside
it.


Mike Beckerle | OGF DFDL Workgroup Co-Chair | Tresys Technology |
www.tresys.com
Please note: Contributions to the DFDL Workgroup's email discussions are
subject to the OGF Intellectual Property
Policy<http://www.ogf.org/About/abt_policies.php>



On Tue, Oct 8, 2013 at 10:21 AM, Garriss Jr., James P.
<jgarriss at mitre.org>wrote:

>  (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****
>
> --
>   dfdl-wg mailing list
>   dfdl-wg at ogf.org
>   https://www.ogf.org/mailman/listinfo/dfdl-wg
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.ogf.org/pipermail/dfdl-wg/attachments/20131008/6d496934/attachment.html>


More information about the dfdl-wg mailing list