W3C home > Mailing lists > Public > xmlschema-dev@w3.org > August 2001

"unorderedness" of child elements?

From: <chuck.han@autodesk.com>
Date: Mon, 20 Aug 2001 15:14:22 -0400 (EDT)
Message-ID: <258E47267E4BD3118DCA00805FA72E080831F84A@hqmsgsrf03.autodesk.com>
To: xmlschema-dev@w3.org
Cc: olivier.loopuyt@httv.fr, forge@neonics.com
I'm trying to write a schema that cares about the cardinality of child elements, but not about the order.  For example, let's say I have an element "parent" that has three child elements ("child1," "child2," and "child3"), I don't care about the order, but "child3" can have an unbounded number of instances.  Because of the unbounded nature of "child3," I understand that I cannot use the "xsd:all" construct.  I have come up with the following solution:
 
    <xsd:element name="parent">
        <xsd:sequence>
            <xsd:choice>
                <xsd:sequence>
                    <xsd:element ref="child1"/> 
                    <xsd:element ref="child2"/> 
                    <xsd:element ref="child3" maxOccurs="unbounded"/>
                </xsd:sequence> 
                <xsd:sequence>
                    <xsd:element ref="child1"/> 
                    <xsd:element ref="child3" maxOccurs="unbounded"/>
                    <xsd:element ref="child2"/> 
                </xsd:sequence> 
                <xsd:sequence>
                    <xsd:element ref="child2"/> 
                    <xsd:element ref="child1"/> 
                    <xsd:element ref="child3" maxOccurs="unbounded"/>
                </xsd:sequence> 
                <xsd:sequence>
                    <xsd:element ref="child2"/> 
                    <xsd:element ref="child3" maxOccurs="unbounded"/>
                    <xsd:element ref="child1"/> 
                </xsd:sequence>
                <xsd:sequence>
                    <xsd:element ref="child3" maxOccurs="unbounded"/>
                    <xsd:element ref="child1"/> 
                    <xsd:element ref="child2"/> 
                </xsd:sequence>
                <xsd:sequence>
                    <xsd:element ref="child3" maxOccurs="unbounded"/>
                    <xsd:element ref="child2"/> 
                    <xsd:element ref="child1"/> 
                </xsd:sequence>
            <xsd:choice>
        <xsd:sequence>
    </xsd:element>
 
In other words, for a parent with n children, there need to be a "xsd:choice" group with n! "xsd:sequences," but even in this solution, all the "child3" elements would need to be grouped together.  The factorial nature of this issue is a serious memory issue when n becomes large.  Is there any other way to do this "unordering" (there was a previous message concerning using an intermediate style sheet http://lists.w3.org/Archives/Public/xmlschema-dev/2001Mar/0148.html <http://lists.w3.org/Archives/Public/xmlschema-dev/2001Mar/0148.html> , but what if a stylesheet is not an option)?
 
thanks in advance, Chuck
 
Chuck Han, Data Architect
Autodesk, Inc.
+1.415.507.8742
 
Received on Wednesday, 22 August 2001 05:27:28 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Tuesday, 11 January 2011 00:14:23 GMT