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: Sat, 15 Mar 2003 11:38:49 +0000
Message-ID: <100602372105.20030315113849@jenitennison.com>
To: "Scott, Michael Gordon" <Michael.Gordon.Scott@kla-tencor.com>
CC: Sam Carleton <sam@linux-info.net>, xmlschema-dev <xmlschema-dev@w3.org>

Hi Michael,

> I'm confused. Isn't the
>
>         "minOccurs=0"
>
> just what is telling the schema that this particular element that
> it's optional?

In:

  <xs:sequence minOccurs="0">
    <xs:element name="NumWafers" type="xsd:nonNegativeInteger" />
    <xs:element name="Wafers" type="WaferLocations" />
  </xs:sequence>

the sequence as a whole is optional. You are saying that *either* you
have a sequence comprising a <NumWafers> element followed by a
<Wafers> element, or you have nothing at all. If you want to say that
a particular element is optional, use minOccurs="0" on the
<xs:element> element for that element.

I was actually misremembering the spec; putting minOccurs="0" on an
<xs:all> element is fine. You should be able to do:

  <xs:all minOccurs="0">
    <xs:element name="NumWafers" type="xsd:nonNegativeInteger" />
    <xs:element name="Wafers" type="WaferLocations" />
  </xs:all>

in order to get <NumWafers> and <Wafers> to appear in any order.
  
Cheers,

Jeni

---
Jeni Tennison
http://www.jenitennison.com/
Received on Saturday, 15 March 2003 06:39:03 GMT

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