W3C home > Mailing lists > Public > xmlschema-dev@w3.org > January 2010

Re: Need something like xs:sequence without order?

From: <noah_mendelsohn@us.ibm.com>
Date: Thu, 28 Jan 2010 17:31:17 -0500
To: Felix Nensa <nensa@zeec.biz>
Cc: xmlschema-dev@w3.org, xmlschema-dev-request@w3.org
Message-ID: <OFE8FAADD6.F1B44D85-ON852576B9.007B43EE-852576B9.007BAD0C@lotus.com>
In schema 1.0:

        <xsd:choice minOccurs="0" maxOccurs="unbounded">
                <xsd:element ref="A" />
           ....references to A,B,C

In schema 1.1:

                <xsd:element ref="A" />
                <xsd:element ref="D" minOccurs="0" maxOccurs="2>

In other words, in schema 1.0, you can use choice, but you don't get to 
tightly control the number of occurrences of each named element.   Schema 
1.1 can do the same, but it also allows you to use <xsd:all> with explicit 
occurrence counts.  That could enforce, for example, that you wanted at 
most two "D" elements, regardless of order with respect to the others. 
Note that XSD 1.1 is still in Candidate Recommendation status and is not 
yet widely deployed.


Noah Mendelsohn 
IBM Corporation
One Rogers Street
Cambridge, MA 02142

Felix Nensa <nensa@zeec.biz>
Sent by: xmlschema-dev-request@w3.org
01/28/2010 12:04 PM
        To:     xmlschema-dev@w3.org
        cc:     (bcc: Noah Mendelsohn/Cambridge/IBM)
        Subject:        Need something like xs:sequence without order?

Hi experts,

I have some tricky XML that needs to be validated against an XSD, that I 
am not sure how to define.
The XML could come in several variations. Some examples:

Example 1:


Example 2:


Example 3:


The corresponding XSD that I would like to define (but of course is 
invalid) would look like this:

<xs:element name="SomeElement">
     <xs:element name="A" type="xs:string" minOccurs="1" maxOccurs="1" />
     <xs:element name="B" type="xs:string" minOccurs="1" maxOccurs="1" />
     <xs:element name="C" type="xs:string" minOccurs="0" maxOccurs="1" 
     <xs:element name="D" type="xs:string" minOccurs="1" 
maxOccurs="unbounded" />                                                

Any ideas how to achive the same with valid XSD?
Thanks in advance,

Received on Thursday, 28 January 2010 22:31:53 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 23:15:55 UTC