W3C home > Mailing lists > Public > xmlschema-dev@w3.org > August 2002

RE: Inheritance of restriction facets?

From: zze-MARCHEGAY Michael stagiaire FTRD/DTL/LAN <michael.marchegay@rd.francetelecom.com>
Date: Fri, 2 Aug 2002 09:01:40 +0200
Message-ID: <0489A7888F080B4BA73B53F7E145F29A1B0B01@LANMHS20.rd.francetelecom.fr>
To: "Eddie Robertsson" <erobertsson@allette.com.au>
Cc: <xmlschema-dev@w3.org>

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 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Tuesday, 11 January 2011 00:14:34 GMT