RE: Inheritance of restriction facets?

Hi Eddie,

I'm sorry to have submitted an invalid schema. But would it have been 
invalid if I had written the following schema instead?

<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  <xsd:simpleType name="foo">
      <xsd:restriction base="xsd:string">
        <xsd:enumeration value="A"/>
        <xsd:enumeration value="AA"/>
        <xsd:enumeration value="AAA"/>
      </xsd:restriction>
  </xsd:simpleType>

  <xsd:element name="bar">
    <xsd:simpleType>
      <xsd:restriction base="foo">
        <xsd:minLength value="2"/>
      </xsd:restriction>
    </xsd:simpleType>
  </xsd:element>
</xsd:schema>

XML Spy 4.3 validates this schema but sqc doesn't. It complains that 
<xsd:minLength value="2"/> is not compatible with the enumeration facets

defined by the ancestors foo, however I can't find out the clause that 
justifies that in the Recommandation.

> 
> Hi Michael,
> 
> >I have a question concerning restriction facets. 
> >When a derivation by restriction of a simpleType is performed, are 
> >the facets of the base type inherited by the deriving type?
> >
> Yes, the facets on the base type are still enforced for the derived 
> types which makes your example below invalid.
> 
> >For example, which content do the following schema allow for 
> bar element?
> >  - A, AA and AAA?
> >  - AA and AAA?
> >  - ...?
> >
> It will never come to this since the schema below is invalid 
> and hence 
> can't be used to validate a document.
> 
> ><schema>
> >  <simpleType name="foo">
> >    <restriction base="string">
> >      <minLength value="2"/>
> >    </restriction>
> >  </simpleType>
> >
> >  <element name="bar">
> >    <simpleType>
> >      <restriction base="foo">
> >        <enumeration value="A"/>
> >
> This is the enumeration value that is invalid. If you remove "A" your 
> schema is fine.
> 
> >        <enumeration value="AA"/>
> >        <enumeration value="AAA"/>
> >      </restriction>
> >    </simpleType>
> >  </element>
> ></schema>
> >
> >Thanks.
> >
> Cheers,
> /Eddie
> 
> 
> 

Received on Friday, 2 August 2002 03:01:42 UTC