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

RE: Choice

From: Naren Chawla <naren_chawla@attbi.com>
Date: Thu, 7 Mar 2002 15:39:42 -0800
To: "Andrew Wilson" <andreww@naa.gov.au>, "'XMLDev'" <xmlschema-dev@w3.org>
Message-ID: <AOEGLCJGIFANMEODKIBGGEPNCBAA.naren_chawla@attbi.com>

My interpretation -

"choice" content model is used to indicate that only one element of the
given list of elements MUST appear.
So, if more than one element appears or no elements appear, both of this are
invalid conditions.

Also, in "<xsd:choice minOccurs="0" maxOccurs="unbounded">" - minOccurs
refer to entire "choice" group as opposed to elements within the choice. So
the entire choice group may not occur at all. And that's perfectly valid.

So, if you want to say - "none of the elements have to be used but ANY ONE
of them
can be used as many times as needed", you will probably have to express as
below -

  <element ref="A" minOccurs="0" maxOccurs="unbounded"/>
  <element ref="C" minOccurs="0" maxOccurs="unbounded"/>
  <element ref="D" minOccurs="0" maxOccurs="unbounded"/>

I have tested this with XML Spy and it works !!


-----Original Message-----
From: xmlschema-dev-request@w3.org
[mailto:xmlschema-dev-request@w3.org]On Behalf Of Andrew Wilson
Sent: Thursday, February 21, 2002 5:04 PM
To: 'XMLDev'
Subject: Choice


I'm new to XML schema development so my question might be really simple and
have been answered years ago:)

In the XML Schema Spec. part 1 it says in sect. 3.8.1: "...(choice)
correspond to exactly one of the specified particles;". I read this as
saying one of the particles in the choice group *must* appear.

However, the XML representation summary in 3.8.2 allows a minOccurs for
choice of 0 (nonNegativeInteger). So is the following valid?:

<xsd:choice minOccurs="0" maxOccurs="unbounded">
 <xsd:element ref="A"/>
 <xsd:element ref="B"/>
 <xsd:element ref="C"/>
 <xsd:element ref="D"/>
 <xsd:element ref="E"/>
 <xsd:element ref="F"/>
 <xsd:element ref="G"/>

[I'm trying to say that none of the elements have to be used but any of them
can be used as many times as needed]

If this is correct, how should the statement in 3.8.1 be read?

Andrew Wilson
Received on Thursday, 7 March 2002 18:39:00 UTC

This archive was generated by hypermail 2.3.1 : Wednesday, 7 January 2015 14:55:55 UTC