Re: Cannot do any order and control the maxOccurs.

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 UTC