Re: Inheritance of restriction facets?

Hi Michael,

> 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.

There's no constraint (that I can see) that states that the length
specified in a derived type has to be such that all the enumerations
in the base type are still legal. Indeed, it would be a very weird
derivation by restriction if it didn't allow you to restrict the
values that you were allowed to have.

The above schema looks perfectly fine to me; the bar element can only
have the values 'AA' and 'AAA'.

Cheers,

Jeni

---
Jeni Tennison
http://www.jenitennison.com/

Received on Sunday, 11 August 2002 12:38:08 UTC