Re: Order indicators in the .xsd file

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
Saxonica

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