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

RE: allowing zero to unbounded elements in any order?

From: Scott, Michael Gordon <Michael.Gordon.Scott@kla-tencor.com>
Date: Fri, 14 Mar 2003 10:05:48 -0800
Message-ID: <4D831CAE736A2741B4513957197C9AEB02FA0C40@CA1XPR10>
To: "'Jeni Tennison'" <jeni@jenitennison.com>, Sam Carleton <sam@linux-info.net>
Cc: xmlschema-dev <xmlschema-dev@w3.org>


I had a case where I needed to do this as well.  Your solution is
intriguing, but I'm confused.  What if I wanted a list similar to : 


Where I could have multiple copies of <C/>, but I wanted to allow B, C, D,
and E to be any order.  After a few days of trying to accomplish that, I
gave up, and used <xs:sequence> instead, and force my users to live with

Michael Scott
KLA-Tencor, Defect Yield Solutions Division

 -----Original Message-----
From: 	Jeni Tennison [mailto:jeni@jenitennison.com] 
Sent:	Friday, March 14, 2003 4:30 AM
To:	Sam Carleton
Cc:	xmlschema-dev
Subject:	Re: allowing zero to unbounded elements in any order?

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 13:06:06 UTC

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