RE: Schema Component Constraint: Element Declarations Consistent

> -----Original Message-----
> From: Michael Kay [mailto:mhk@mhk.me.uk] 
> Sent: Friday, February 13, 2004 8:43 AM
> To: xmlschema-dev@w3.org
> Subject: Schema Component Constraint: Element Declarations Consistent
> 
> In the rule for consistency of element declarations within a 
> model group, why is it required that the type of an element 
> that appears twice be a named top-level type?
> 
> But the following is not:
> 
> <complexType name="cType">
>  <sequence>
>   <element ref="a"/>
>   <element ref="a"/>
>  </sequence>
> </complexType>
> 
> <element name="a">
>  <complexType>
>    <simpleContent base="xs:string"/>
>  </complexType>
> </element>

I'm sure henry can give a more precise explanation, but the above seems to me to be correct (which is backed up by xsv 2.6.2 and xerces 2.6.1).  I think the reason that the above does not run afould of the Element Declaration Consistent [1] schema constraint is that the use of element _references_ in the model group in question means that, in fact, there is only one element declaration involved here...so that constraint never comes into question.

I'd note that the following is in violation:

<xs:complexType name="cType">
 <xs:sequence>
  <xs:element name="a">
   <xs:complexType>
    <xs:simpleContent>
     <xs:extension base="xs:string"/>
    </xs:simpleContent>
   </xs:complexType>
  </xs:element>
  <xs:element name="a">
   <xs:complexType>
    <xs:simpleContent>
     <xs:extension base="xs:string"/>
    </xs:simpleContent>
   </xs:complexType>
  </xs:element>
 </xs:sequence>
</xs:complexType>

[which, BTW, corrects a type in your original example]

since the 2 "a" elements in the model do in fact have separate (but equal :-) definitions.

pvb

Received on Friday, 13 February 2004 12:08:27 UTC