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

Re: <xsd:sequence> required?

From: Eddie Robertsson <erobertsson@allette.com.au>
Date: Mon, 11 Feb 2002 07:01:26 -0500 (EST)
Message-ID: <3C67B4D7.7A808D2@allette.com.au>
To: a.cuellar@auckland.ac.nz
CC: xmlschema-dev@w3.org
> What I want to be able to say with the following piece of code is that
> one can use the mentioned elements any number of times and in any order.
>
>    <xsd:complexType name="ModelType">
>      <xsd:element ref="cellml:units" minOccurs="0
> maxOccurs="unbounded"/>
>      <xsd:element ref="cellml:component" minOccurs="0"
>        maxOccurs="unbounded" />
>      <xsd:element ref="cellml:group" minOccurs="0"
>        maxOccurs="unbounded"/>
>      <xsd:element ref="cellml:connection" minOccurs="0"
>        maxOccurs="unbounded" />
>      <xsd:element ref="rdf:RDF" minOccurs="0" maxOccurs="unbounded" />
>      <xsd:attribute ref="cellml:name" use="required" />
>      <xsd:attribute ref="cmeta:id" use="optional" />
>    </xsd:complexType>
>
> Since the children elements can be in any order, the <xsd:sequence>
> element is not useful.  Neither are the <xsd:choice> and <xsd:all>.  Is
> it necessary that I use one of them in this case?

Yes, you always need to have one of sequence, all or choice specified. Since
you want all elements to appear any number of times and in any order you can
add minOccurs="0" and maxOccurs="unbounded" to the choice element itself.
So, you would have:

   <xsd:complexType name="ModelType">
    <xsd:choice minOccurs="0" maxOccurs="unbounded">
     <xsd:element ref="cellml:units" minOccurs="0
maxOccurs="unbounded"/>
     <xsd:element ref="cellml:component" minOccurs="0"
       maxOccurs="unbounded" />
     <xsd:element ref="cellml:group" minOccurs="0"
       maxOccurs="unbounded"/>
     <xsd:element ref="cellml:connection" minOccurs="0"
       maxOccurs="unbounded" />
     <xsd:element ref="rdf:RDF" minOccurs="0" maxOccurs="unbounded" />
    </xsd:choice>
    <xsd:attribute ref="cellml:name" use="required" />
    <xsd:attribute ref="cmeta:id" use="optional" />
   </xsd:complexType>

Cheers,
/Eddie
Received on Tuesday, 12 February 2002 05:20:45 GMT

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