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

Re: xml:all

From: Jeni Tennison <jeni@jenitennison.com>
Date: Thu, 5 Sep 2002 14:28:58 +0100
Message-ID: <1122073535195.20020905142858@jenitennison.com>
To: andrew.curry@pa.press.net
CC: xmlschema-dev@w3.org

Hi Andrew,

> I am currently trying to write part of a schema to allow a number of
> elements with multiple occurances in any order.
> What i would idealy like to do is:
> <xs:all>
>       <xs:element ref="mls:Score" minOccurs="0" maxOccurs="unbounded"/>
>       <xs:element ref="mls:Goal" minOccurs="0" maxOccurs="unbounded"/>
>       <xs:element ref="mls:Shot" minOccurs="0" maxOccurs="unbounded"/>
> </xs:all>
>
> Sadly xs:all must have maxOcurres of 1 so this is not possible. Does
> anyone know of any other possible solutions/work arounds?

With this particular example, you can use:

  <xs:choice minOccurs="0" maxOccurs="unbounded">
    <xs:element ref="mls:Score" />
    <xs:element ref="mls:Goal" />
    <xs:element ref="mls:Shot" />
  </xs:choice>

If you wanted to place more restrictions on the occurrence of the
elements -- for example to say that there must be at least one Score
element or less than 10 Goal elements -- then you would have to have
an extra validation step (for example using Schematron) to check that
constraint.
  
Cheers,

Jeni

---
Jeni Tennison
http://www.jenitennison.com/
Received on Thursday, 5 September 2002 09:36:43 GMT

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