#613 Types derived by restriction then extension

v8.8
closed
Michael Kay
5
2012-10-08
2006-10-24
Michael Kay
No

Consider the following schema:

<xs:complexType name="alpha">
<xs:sequence>
<xs:element name="a"/>
<xs:element name="b" type="xs:integer" minOccurs="0"/>
</xs:sequence>
</xs:complexType>

<xs:complexType name="beta">
<xs:complexContent>
<xs:restriction base="alpha">
<xs:sequence>
<xs:element name="a"/>
</xs:sequence>
</xs:restriction>
</xs:complexContent>
</xs:complexType>

<xs:complexType name="gamma">
<xs:complexContent>
<xs:extension base="beta">
<xs:sequence>
<xs:element name="b" type="xs:anyURI"/>
</xs:sequence>
</xs:extension>
</xs:complexContent>
</xs:complexType>

This is invalid under Schema Component Constraint:
Derivation Valid (Extension) clause 1.5. Saxon however
accepts this schema as valid (as do most other schema
processors, apparently).

Using an instance that has been validated against this
schema can cause a ClassCastException because an
operation such as $x/b+1 expects an xs:integer but
receives an xs:anyURI.

The problem will be fixed in a future release by
recognizing such schemas as invalid.

Discussion