- 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
In schema 1.0: <xsd:choice minOccurs="0" maxOccurs="unbounded"> <xsd:element ref="A" /> etc. ....references to A,B,C In schema 1.1: <xsd:all> <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 -------------------------------------- Noah Mendelsohn IBM Corporation One Rogers Street Cambridge, MA 02142 1-617-693-4036 -------------------------------------- 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: <SomeElement> <A>aaa</A> <B>bbb</B> <C>ccc</C> <D>ddd</D> <D>dde</D> </SomeElement> Example 2: <SomeElement> <B>bbb</B> <A>aaa</A> <C>ccc</C> <D>ddd</D> <D>dde</D> </SomeElement> Example 3: <SomeElement> <B>bbb</B> <A>aaa</A> <D>ddd</D> <D>dde</D> </SomeElement> The corresponding XSD that I would like to define (but of course is invalid) would look like this: <xs:element name="SomeElement"> <xs:complexType> <xs:all> <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" /> </xs:all> </xs:complexType> </xs:element> Any ideas how to achive the same with valid XSD? Thanks in advance, Felix
Received on Thursday, 28 January 2010 22:31:53 UTC