<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://www.w3.org/Bugs/Public/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4"
          urlbase="https://www.w3.org/Bugs/Public/"
          
          maintainer="sysbot+bugzilla@w3.org"
>

    <bug>
          <bug_id>2222</bug_id>
          
          <creation_ts>2005-09-14 19:22:42 +0000</creation_ts>
          <short_desc>R-230: Question on maxOccurs=0, particles and restriction</short_desc>
          <delta_ts>2009-04-21 19:21:37 +0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>XML Schema</product>
          <component>Structures: XSD Part 1</component>
          <version>1.1 only</version>
          <rep_platform>All</rep_platform>
          <op_sys>All</op_sys>
          <bug_status>CLOSED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard>medium, easy, restriction cluster</status_whiteboard>
          <keywords>resolved</keywords>
          <priority>P4</priority>
          <bug_severity>normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Sandy Gao">sandygao</reporter>
          <assigned_to name="C. M. Sperberg-McQueen">cmsmcq</assigned_to>
          
          
          <qa_contact name="XML Schema comments list">www-xml-schema-comments</qa_contact>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>6245</commentid>
    <comment_count>0</comment_count>
    <who name="Sandy Gao">sandygao</who>
    <bug_when>2005-09-14 19:22:42 +0000</bug_when>
    <thetext>Please clarify an issue regarding the use of maxOccurs=&quot;0&quot;, particularly within 
a type derived by &lt;restriction&gt; 

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

1. Where minOccurs=maxOccurs=0, the item &quot;corresponds to no component at all.&quot; 
[repeated] 

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

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

Also, from the Primer: 

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

5. In restriction, minOccurs=&quot;0&quot; and maxOcurs=&quot;0&quot; means &quot;exclusion of an 
optional component.&quot; 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=&quot;0&quot; while (3) says this would not be a correct particle. Is 
an incorrect particle still a particle?? I&apos;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 &apos;prohibit&apos; or can explicitly 
prohibit it by specifying maxOccurs=&quot;0&quot; and this should mean the same thing. 
However, (3) implies that the latter would not validate. 

E.g.

   &lt;complexType name=&quot;base&quot;&gt;
     &lt;sequence&gt;
       &lt;element name=&quot;a&quot; minOccurs=&quot;0&quot; maxOccurs=&quot;1&quot;/&gt;
       &lt;element name=&quot;b&quot; minOccurs=&quot;0&quot; maxOccurs=&quot;1&quot;/&gt;
       &lt;element name=&quot;c&quot; minOccurs=&quot;0&quot; maxOccurs=&quot;1&quot;/&gt;
     &lt;/sequence&gt;
   &lt;/complexType&gt;

   &lt;complexType name=&quot;deriveByOmission&quot;&gt;
     &lt;complexContent&gt;
       &lt;restriction base=&quot;base&quot;&gt;
         &lt;sequence&gt;
           &lt;element name=&quot;a&quot; minOccurs=&quot;0&quot; maxOccurs=&quot;1&quot;/&gt;
           &lt; prohibit element &quot;b&quot; by omission --&gt;
           &lt;element name=&quot;c&quot; minOccurs=&quot;0&quot; maxOccurs=&quot;1&quot;/&gt;
         &lt;/sequence&gt;
       &lt;/restriction&gt;
     &lt;/complexContent&gt;
   &lt;/complexType&gt;

   &lt;complexType name=&quot;deriveByZeroOccurrence&quot;&gt;
     &lt;complexContent&gt;
       &lt;restriction base=&quot;base&quot;&gt;
         &lt;sequence&gt;
           &lt;element name=&quot;a&quot; minOccurs=&quot;0&quot; maxOccurs=&quot;1&quot;/&gt;
           &lt;element name=&quot;b&quot; minOccurs=&quot;0&quot; maxOccurs=&quot;0&quot;/&gt; &lt;!-- prohibit
element &quot;b&quot; --&gt;
           &lt;element name=&quot;c&quot; minOccurs=&quot;0&quot; maxOccurs=&quot;1&quot;/&gt;
         &lt;/sequence&gt;
       &lt;/restriction&gt;
     &lt;/complexContent&gt;
   &lt;/complexType&gt;

(Helpfully, of the seven schema tools I&apos;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</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>12982</commentid>
    <comment_count>1</comment_count>
    <who name="Sandy Gao">sandygao</who>
    <bug_when>2006-11-22 04:08:46 +0000</bug_when>
    <thetext>Both derivation should be valid. &quot;deriveByOmission&quot; and &quot;deriveByZeroOccurrence&quot; will have the same content model, because minOccurs=maxOccurs=0 &quot;corresponds to no component at all.&quot;

#2 and #3 are confusing.

Proposal: to change the component description and disallow &quot;0&quot; as a valid value for maxOccurs. And to remove &quot;{max occurs} must be greater than or equal to 1&quot; from &quot;Particle Correct&quot;.

Resolution: adopted at 2006-11-17 telecon.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>