W3C home > Mailing lists > Public > xmlschema-dev@w3.org > March 2003

Re: Order of elements in a complex-type (XSD)

From: Jeni Tennison <jeni@jenitennison.com>
Date: Wed, 5 Mar 2003 16:18:44 +0000
Message-ID: <18509213750.20030305161844@jenitennison.com>
To: Dinesh Sankaralingam <dsankara@cook-hurlbert.com>
CC: xmlschema-dev@w3.org

Hi Dinesh,

> I want to make the order of elements to be immaterial in
> complex-type definition. But at the same time, I want to make the
> maximum occurance of one or two elements to be unbound. Is it
> possible to do that? When i have "xs:all", then i have make all the
> child element's maxOccurs = 1. But i want to make some elements to
> have "unbound" for maxoccurs. If i use "xs:choice", then all the
> child elements have maxOccurs="unbound".

You can't use <xs:all> to create a content model in which elements may
appear more than once.

So you have to use a content model like:

  (E4*, ((E3, E4*, t:Test1_Root) | (t:Test1_Root, E4*, E3)), E4*)

to get the elements to appear in any order with only one E3 and one
t:Test1_Root element.

Or you can use a looser content model and then use Schematron to add
the restrictions that E3 and t:Test1_Root have to appear only once.

Or you can have a tighter content model, in which the order of the
elements is fixed, and normalise your XML into that order prior to
validation.

Cheers,

Jeni

---
Jeni Tennison
http://www.jenitennison.com/
Received on Wednesday, 5 March 2003 11:19:41 GMT

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