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

Re: allowing zero to unbounded elements in any order?

From: Jeni Tennison <jeni@jenitennison.com>
Date: Fri, 14 Mar 2003 12:29:48 +0000
Message-ID: <41519031297.20030314122948@jenitennison.com>
To: Sam Carleton <sam@linux-info.net>
CC: xmlschema-dev <xmlschema-dev@w3.org>

Hi Sam,

> I am trying to define a element that contains text and can
> optionally contain one or more <b> elements and/or <i> elements in
> any order. How do I define that? This is what I have so far:
>   <xs:complexType name="stringType" mixed="true">
>     <xs:all minOccurs="0">
>       <xs:element ref="b"/>
>       <xs:element ref="i"/>
>     </xs:all>
>   </xs:complexType>
>   <xs:element name="i" type="xs:string"/>
>   <xs:element name="b" type="xs:string"/>

You can't use <xs:all> for repeatable elements, but a repeating
<xs:choice> works nicely. Try:

  <xs:choice minOccurs="0" maxOccurs="unbounded">
    <xs:element ref="b" />
    <xs:element ref="i" />

for zero to unbounded (as per the subject line of your email) or:

  <xs:choice maxOccurs="unbounded">
    <xs:element ref="b" />
    <xs:element ref="i" />

for one to unbounded (as per the text of your email).



Jeni Tennison
Received on Friday, 14 March 2003 07:30:01 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 23:15:09 UTC