W3C home > Mailing lists > Public > xmlschema-dev@w3.org > October 2012

Re: Order indicators in the .xsd file

From: Michael Kay <mike@saxonica.com>
Date: Wed, 17 Oct 2012 15:45:49 +0100
Message-ID: <507EC49D.20502@saxonica.com>
To: xmlschema-dev@w3.org

On 16/10/2012 23:13, Fred Li wrote:
> Hi XML experts,
> I have a problem about the use of order indicators in the creation of
> XML schema (.xsd file). As I learned from W3School
> (http://www.w3schools.com/schema/schema_complex_indicators.asp),  we
> have 3 order indicators in the XML Schema language:
Note that the w3schools site has no connection with W3C, and in this 
instance they have chosen to present their tutorial using concepts and 
language that are unrelated to anything found in the W3C specification.
> All - the child elements can appear in any order, and each child
> element must occur only once
> Choice - either one child element or another can occur
> Sequence - the child elements must appear in a specific order
> I have an element (for example <asset>) that has 23 child elements,
> three of them can have more than 1 instances, and 7 of them are
> required (includes the 3 have more than 1 instances). According to the
> definition of the order indicators, "sequence" is the only indicator I
> can use in the XML schema, but I hope there is no order restriction
> for the appearance of  23 child elements. Do you have any ideas to
> solve this problem?
In XSD 1.1 you can use xs:all combined with a minOccurs and maxOccurs 
value for each element.

In XSD 1.0 you can't: if you want to allow the elements to appear in any 
order, then you can't control how many times each of them appears 
(except by an enumeration of permutations which in this case would be 
quite impracticably long).

So the answer depends on whether you have access to an XSD 1.1 processor.

Michael Kay
Received on Wednesday, 17 October 2012 14:46:21 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 23:16:02 UTC