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

Re: xsd:group and minOccurs

From: Jeni Tennison <jeni@jenitennison.com>
Date: Thu, 29 Aug 2002 09:14:10 +0100
Message-ID: <1191449857454.20020829091410@jenitennison.com>
To: xmlschema-dev@w3.org, Eddie Robertsson <erobertsson@allette.com.au>
CC: "Gregory M. Messner" <gmessner@breezefactor.com>

Hi Eddie,

>>Since the "agroup" reference in the "test" element has an implied
>>minOccurs="1" would a document with an empty "test" element be valid against
>>the schema?
> Yes, I believe this would be valid. I think the place for this in
> the spec is "3.8.4 Model Group Validation Rule" [1] which has the
> following paragraph:
> "Nothing in the above should be understood as ruling out groups whose 
> {particles} is empty: although no sequence can be ·valid· with respect 
> to such a group whose {compositor} is choice, the empty sequence is 
> ·valid· with respect to empty groups whose {compositor} is sequence or 
> all. "
> So, this means that for <all> and <sequence> you are allowed to have 
> empty particles but for <choice> this would not be valid.

I agree with your conclusion, but now with how you got to it. A group
whose {particles} is empty is a group that doesn't specify any
particles, for example:

  <xs:sequence />


  <xs:choice />


  <xs:all />

A sequence or an all group with no particles, as above, is fine -- it
just means that it matches an empty sequence of elements in the
instance. Having a choice between an empty set of particles is
invalid, on the other hand, because each time you have a choice you
must choose something, and if you have nothing to choose from then you
cannot choose anything :)

A model group like:

    <xsd:element name="A" minOccurs="0" type="xsd:string" />
    <xsd:element name="B" minOccurs="0" type="xsd:string" />
    <xsd:element name="C" minOccurs="0" type="xsd:string" />

is a choice model group that has three element particles. All those
particles are *optional* (have a minimum occurrence of 0) but the
model group still has particles. So this is perfectly valid



Jeni Tennison
Received on Thursday, 29 August 2002 04:14:22 UTC

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