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

RE: Choice

From: Beyer,Nathan <NBEYER@cerner.com>
Date: Fri, 8 Mar 2002 07:59:04 -0600
Message-ID: <68ADFB4BE17A614B80FFFF6CDBC1A8160C6A7905@mailwhq1.cerner.com>
To: "Schema Dev XML (E-mail)" <xmlschema-dev@w3.org>
I don't believe the second example given is correct, even though XMLSpy
validates. I'd recommend trying to validate that in Xerces or some other
validator. XMLSpy validates a number of things it shouldn't.

I've always been under the impression that when "choice" is used, all
minOccurs and maxOccurs attribute within the content model are ignored. I've
been trying find proof of this in the spec, but have been unsuccessful so
far. Can anyone confirm or deny this?

Also, using <choice minOccurs="0" maxOccurs="unbounded"> will solve the
"none of the elements have to be used but ANY ONE of them can be used as
many times as needed" problem.

The way I always look at it is the minOccurs and the maxOccurs on the choice
tells you how many times you have to make that choice and/or can make that
choice. In the above case you don't have to make the choice at, but if you
do, you can do so as many times as you want. This could result in choosing
every element within the choice, in any order.

That's my 2 cents.


-----Original Message-----
From: Naren Chawla [mailto:naren_chawla@attbi.com]
Sent: Thursday, March 07, 2002 5:40 PM
To: Andrew Wilson; 'XMLDev'
Subject: RE: Choice


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

This message and any included attachments are from Cerner Corporation and are intended only for the addressee. The information contained in this message is confidential and may constitute inside or non-public information under international, federal, or state securities laws. Unauthorized forwarding, printing, copying, distribution, or use of such information is strictly prohibited and may be unlawful. If you are not the addressee, please promptly delete this message and notify the sender of the delivery error by e-mail or you may call Cerner's corporate offices in Kansas City, Missouri, U.S.A at (+1) (816)221-1024.
Received on Friday, 8 March 2002 08:59:29 UTC

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