So, I’m trying to create a schema, whereby I use one schema as a reference and never touch and another schema where I can touch, extend, restrict etc. So the problem I’m having now is that I’m faced with a restraint rcase-NameAndTypeOK3.2.5.
<!--Msg -->
<xs:complexType name="Main">
<xs:complexContent>
<xs:restriction base="B">
<xs:sequence>
<xs:element name="B1" type="BType"/>
<xs:element name="B2" type="BType"/>
<xs:element name="B3" type="B3-Type"/>
</xs:sequence>
</xs:restriction>
</xs:complexContent>
</xs:complexType>
<!-- Types -->
<xs:complexType name="B3-Type">
<xs:complexContent>
<xs:extension base="BType">
<xs:sequence>
<xs:element name="B-4"/>
</xs:sequence>
</xs:extension>
</xs:complexContent>
</xs:complexType>
<!-- Source -->
<xs:complexType name="BType">
<xs:sequence>
<xs:element name="B-1"/>
<xs:element name="B-2"/>
<xs:element name="B-3"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="B">
<xs:sequence>
<xs:element name="B1" type="BType"/>
<xs:element name="B2" type="BType"/>
<xs:element name="B3" type="BType"/>
</xs:sequence>
</xs:complexType>
I have a work around, and that is removing the restriction in Main. Is there another workaround without removing the restriction in Main? Is there something I’m doing wrong?
I don’t see another workaround – the problem is that
Mainas defined is not a restriction nor an extension ofB– being that it can contain an elementB3asBbut with one extra sub-elementB-4.If you want to have a fixed base schema and then a derived schema with some declaration equal to the base one and some other different probably you should use
xsd:redefine