Derivation by restriction

Our implementation of an XML schema validator considers the following document invalid
 
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema <http://www.w3.org/2001/XMLSchema> "
elementFormDefault="qualified" attributeFormDefault="unqualified">
 <xs:element name="Address">
  <xs:complexType>
   <xs:sequence>
    <xs:element name="aPossibleAddress" type="Address_t"/>
    <xs:element name="aRealAddress" type="EnteredAddress_t"/>
   </xs:sequence>
  </xs:complexType>
 </xs:element>
 <xs:complexType name="Address_t">
  <xs:sequence>
   <xs:element name="theAddressString" minOccurs="0">
    <xs:simpleType>
     <xs:restriction base="xs:string">
      <xs:maxLength value="50"/>
     </xs:restriction>
    </xs:simpleType>
   </xs:element>
  </xs:sequence>
 </xs:complexType>
 <xs:complexType name="EnteredAddress_t">
  <xs:complexContent>
   <xs:restriction base="Address_t">
    <xs:sequence>
     <xs:element name="theAddressString">
      <xs:simpleType>
       <xs:restriction base="xs:string">
        <xs:maxLength value="50"/>
       </xs:restriction>
      </xs:simpleType>
     </xs:element>
    </xs:sequence>
   </xs:restriction>
  </xs:complexContent>
 </xs:complexType>
 <xs:simpleType name="AddressString_t">
  <xs:restriction base="xs:string">
   <xs:maxLength value="50"/>
  </xs:restriction>
 </xs:simpleType>
</xs:schema>

and considers this one as valid
 
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema <http://www.w3.org/2001/XMLSchema> "
elementFormDefault="qualified" attributeFormDefault="unqualified">
 <xs:element name="Address">
  <xs:complexType>
   <xs:sequence>
    <xs:element name="aPossibleAddress" type="Address_t"/>
    <xs:element name="aRealAddress" type="EnteredAddress_t"/>
   </xs:sequence>
  </xs:complexType>
 </xs:element>
 <xs:complexType name="Address_t">
  <xs:sequence>
   <xs:element name="theAddressString" type="AddressString_t"
minOccurs="0"/>
  </xs:sequence>
 </xs:complexType>
 <xs:complexType name="EnteredAddress_t">
  <xs:complexContent>
   <xs:restriction base="Address_t">
    <xs:sequence>
     <xs:element name="theAddressString" type="AddressString_t"/>
    </xs:sequence>
   </xs:restriction>
  </xs:complexContent>
 </xs:complexType>
 <xs:simpleType name="AddressString_t">
  <xs:restriction base="xs:string">
   <xs:maxLength value="50"/>
  </xs:restriction>
 </xs:simpleType>
</xs:schema>
 
 
Because of the XML Schema Structures recommendation section 
    Schema Component Constraint: Particle Derivation OK (Elt:Elt - NameAndTypeOK) [0] 
        #7  and NOTE
 
7 R's {type definition} <http://www.w3.org/TR/xmlschema-1/#type_definition>  is validly derived given {extension, list, union} from B's {type definition} <http://www.w3.org/TR/xmlschema-1/#type_definition>  as defined by Type Derivation OK (Complex) (§3.4.6) <http://www.w3.org/TR/xmlschema-1/#cos-ct-derived-ok>  or Type Derivation OK (Simple) (§3.14.6) <http://www.w3.org/TR/xmlschema-1/#cos-st-derived-ok> , as appropriate. 

	NOTE: The above constraint on {type definition} <http://www.w3.org/TR/xmlschema-1/#type_definition>  means that in deriving a type by restriction, any contained type definitions must themselves be explicitly derived by restriction from the corresponding type definitions in the base definition. 

 
However this runs contrary to both the text in 'Essential XML Quick Reference' on XML Schema xs:restriction (p. 337) and the example in the XML Schema Primer[1] which imply that
simply defining the contained type again in a derived type without the contained type deriving by restriction is allowable. XML Spy also validates both schemas. 
 
So are we interpreting the recommendation correctly or not?  
 
[0] http://www.w3.org/TR/xmlschema-1/#rcase-NameAndTypeOK
[1] http://www.w3.org/TR/xmlschema-0/#DerivByRestrict <http://www.w3.org/TR/xmlschema-0/#DerivByRestrict>  
-- 
THINGS TO DO IF I BECOME AN EVIL OVERLORD #110
I will not employ devious schemes that involve the hero's party getting into 
my inner sanctum before the trap is sprung.
 

Received on Friday, 22 February 2002 15:06:17 UTC