Problems with restriction
Posted: Thu Jun 26, 2003 6:32 pm
Hi,
Looks like there are problems with restriction.
Here is an example xsd:
Basically I have an enum tPredefinedEnum allowing CBR and DIS as values. Then, I have two types, tSuper and its sub-type tSub. tSuper has an attribute dummy of that tPredefinedEnum type.
tSub is a restriction of tSuper, by fixing the value of the dummy attribute to DIS.
This seems perfectly valid to me and other validators do accept this. oXygen does however complain:
- [ OxygenBugs.xsd] E derivation-ok-restriction.2.1.2: Error for type 'tSub'. An attribute use in this type has a type which is not validly derived from the type of the matching attribute use in the base type. (33:18)
- [ OxygenBugs.xsd] E cos-particle-restrict.2: Forbidden particle restriction: 'any:choice,sequence,all,elt'. (30:30)
- [ OxygenBugs.xsd] E derivation-ok-restriction.5.3.2: Error for type 'tSub'. The particle of the type is not a valid restriction of the particle of the base. (30:30)
Are restrictions not supported or am I doing something wrong?
Thanks!
Chris
Looks like there are problems with restriction.
Here is an example xsd:
Code: Select all
<?xml version="1.0" encoding="UTF-8"?>
<!-- edited with XMLSPY v5 rel. 4 U (http://www.xmlspy.com) by Christian Frei (ABB Schweiz, Corp. Research) -->
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" attributeFormDefault="unqualified">
<xs:element name="super" type="tSuper">
<xs:annotation>
<xs:documentation>Comment describing your root element</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="sub" type="tSub"/>
<xs:simpleType name="tPredefinedEnum">
<xs:restriction base="xs:Name">
<xs:enumeration value="CBR"/>
<xs:enumeration value="DIS"/>
</xs:restriction>
</xs:simpleType>
<!-- ... cut ... -->
<xs:complexType name="tSuper">
<xs:sequence>
<xs:element name="Text" type="xs:normalizedString"/>
</xs:sequence>
<xs:attribute name="dummy" type="tPredefinedEnum" use="optional"/>
</xs:complexType>
<xs:complexType name="tSub">
<xs:complexContent>
<xs:restriction base="tSuper">
<xs:sequence>
<xs:element name="Text" type="xs:normalizedString"/>
</xs:sequence>
<xs:attribute name="dummy" fixed="DIS"/>
</xs:restriction>
</xs:complexContent>
</xs:complexType>
</xs:schema>
tSub is a restriction of tSuper, by fixing the value of the dummy attribute to DIS.
This seems perfectly valid to me and other validators do accept this. oXygen does however complain:
- [ OxygenBugs.xsd] E derivation-ok-restriction.2.1.2: Error for type 'tSub'. An attribute use in this type has a type which is not validly derived from the type of the matching attribute use in the base type. (33:18)
- [ OxygenBugs.xsd] E cos-particle-restrict.2: Forbidden particle restriction: 'any:choice,sequence,all,elt'. (30:30)
- [ OxygenBugs.xsd] E derivation-ok-restriction.5.3.2: Error for type 'tSub'. The particle of the type is not a valid restriction of the particle of the base. (30:30)
Are restrictions not supported or am I doing something wrong?
Thanks!
Chris