W3C home > Mailing lists > Public > xmlschema-dev@w3.org > February 2002

Re: Cannot do any order and control the maxOccurs.

From: Jeni Tennison <jeni@jenitennison.com>
Date: Wed, 27 Feb 2002 09:32:51 +0000
Message-ID: <951719372.20020227093251@jenitennison.com>
To: Christopher Birkett <christopherbirkett@yahoo.com>
CC: xmlschema-dev@w3.org
Hi Chris,

> XML Schema Limitation:
> 1.  You cannot specify any order and have some, but
> not all, of the elements' frequency greater than one.
[snip]
>          To almost get around this limitation (if we
> want any order and control the frequency) we have 2
> options:
>          1)  We would have to declare <Extension> as
> an XML Schema list type.
[snip]
>          2)  We could specify any order and any
> frequency for all items (choice maxOccurs="unbounded")

A third option would be to define wrapper elements for the elements
that can repeat:

  <App>
    <cn>Word</cn>
    <Extensions>
      <Extension>doc</Extension>
      <Extension>txt</Extension>
    </Extensions>
  </App>

This would allow you to use xs:all to indicate that the elements
within App can go in any order:

  <xs:all>
    <xs:element ref="cn" />
    <xs:element ref="Extensions" />
  </xs:all>

Which would mean that the following is also legal:

  <App>
    <Extensions>
      <Extension>doc</Extension>
      <Extension>txt</Extension>
    </Extensions>
    <cn>Word</cn>
  </App>

The other options, as mentioned on this list recently, are:

 - to list all the possible combinations of orders; this gets unwieldy
   if you have lots of elements that are intermingled.

 - create a canonical schema in which the order is fixed; if
   necessary, you can write a simple script or stylesheet to transform
   instances into documents with this ordering

Out of interest, why is it important to you to allow elements to be in
any order?

Cheers,

Jeni

---
Jeni Tennison
http://www.jenitennison.com/
Received on Wednesday, 27 February 2002 04:32:58 GMT

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