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

http://www.w3.org/Bugs/Public/show_bug.cgi?id=3996

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


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." 
[repeated] 

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 
definitions. 

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. 

E.g.

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

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

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

(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?

See:
http://lists.w3.org/Archives/Public/www-xml-schema-comments/2003JulSep/0042.html

Received on Wednesday, 22 November 2006 04:22:51 UTC