W3C home > Mailing lists > Public > www-xml-schema-comments@w3.org > July to September 2005

[Bug 2222] R-230: Question on maxOccurs=0, particles and restriction

From: <bugzilla@wiggum.w3.org>
Date: Wed, 14 Sep 2005 19:22:42 +0000
To: www-xml-schema-comments@w3.org
Message-Id: <E1EFcqA-0001Je-N0@wiggum.w3.org>


           Summary: R-230: Question on maxOccurs=0, particles and
           Product: XML Schema
           Version: 1.0
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: XSD Part 1: Structures
        AssignedTo: ht@w3.org
        ReportedBy: sandygao@ca.ibm.com
         QAContact: www-xml-schema-comments@w3.org

Please clarify an issue regarding the use of maxOccurs="0", particularly within 
a type derived by <restriction> 

>From various places in the Structures recommendation I have gathered the 
following information: 

1. Where minOccurs=maxOccurs=0, the item "corresponds to no component at all." 

2. The Particle Schema Component: {max occurs} - "Either a non-negative integer 
or unbounded." http://www.w3.org/TR/xmlschema-1/#p-max_occurs 

3. Particle Correct: for all particles "{max occurs} must be greater than or 
equal to 1." http://www.w3.org/TR/xmlschema-1/#p-props-correct 

Also, from the Primer: 

4. An element with minOccurs="0" and maxOccurs="0" means the element "must not 
appear." http://www.w3.org/TR/xmlschema-0/#cardinalityTable 

5. In restriction, minOccurs="0" and maxOcurs="0" means "exclusion of an 
optional component." http://www.w3.org/TR/xmlschema-0/#restrictsTable 

It seems to me that (2) and (3) conflict. (2) effectively says that a particle 
may have maxOccurs="0" while (3) says this would not be a correct particle. Is 
an incorrect particle still a particle?? I'm not sure that (1) excuses this 
conflict. Looking at the Errata I cannot see any substantive changes to these 

The problem I have specifically relates to restriction of a complexType 
containing a sequence. As I understand it, the derived restricted sequence can 
either simply not mention the element I wish to 'prohibit' or can explicitly 
prohibit it by specifying maxOccurs="0" and this should mean the same thing. 
However, (3) implies that the latter would not validate. 


   <complexType name="base">
       <element name="a" minOccurs="0" maxOccurs="1"/>
       <element name="b" minOccurs="0" maxOccurs="1"/>
       <element name="c" minOccurs="0" maxOccurs="1"/>

   <complexType name="deriveByOmission">
       <restriction base="base">
           <element name="a" minOccurs="0" maxOccurs="1"/>
           < prohibit element "b" by omission -->
           <element name="c" minOccurs="0" maxOccurs="1"/>

   <complexType name="deriveByZeroOccurrence">
       <restriction base="base">
           <element name="a" minOccurs="0" maxOccurs="1"/>
           <element name="b" minOccurs="0" maxOccurs="0"/> <!-- prohibit
element "b" -->
           <element name="c" minOccurs="0" maxOccurs="1"/>

(Helpfully, of the seven schema tools I've tried, 5 accept both derivations 
(but given other experiences are maybe just too lax) and 2 refuse both...) 

Which of these 2 derivations are correct?

Received on Wednesday, 14 September 2005 19:22:48 UTC

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