Hi, I'm have come across an interesting issue with restrictions, xerces 2.4 gives me the error "Forbidden restriction of 'choice': All,Seq,Leaf" when trying to validate an XML document against a schema containing the following...
 <xsd:complexType name="base">
  <xsd:sequence>   
   <xsd:choice>    
    <xsd:element name="a" type="xsd:string"/>
    <xsd:element name="b" type="xsd:string"/>
   </xsd:choice>   
   <xsd:element name="c" minOccurs="0" type="xsd:string"/>   
  </xsd:sequence>
 </xsd:complexType>
 
 <xsd:complexType name="derv">
  <xsd:complexContent>
   <xsd:restriction base="base">
    <xsd:sequence>
     <xsd:choice>
      <xsd:element name="a" type="xsd:string"/>
      <xsd:element name="b" type="xsd:string"/>
     </xsd:choice>
    </xsd:sequence>
   </xsd:restriction>
  </xsd:complexContent>
 </xsd:complexType>
 
Now, what I think is happening (correct me if I am wrong) is that Xerces is throwing away the <xsd:sequence> in the 'derv' complexType due to the "Pointless sequence/choice/all" rule from the schema spec, so then when checking if the restriction is valid Xerces finds it is matching a sequence (from base) to a choice (from derv) and hence raises an error.
 
Does anyone have any thoughts, comment or insights into this? Is this a problem with xerces or a problem with the schema spec? To me the restriction seems to be perfectly reasonable.
 
Thanks
Rowan

Reply via email to