Reputation: 6643
I'm looking for a kind of XSD Inheritance that I'm not quite sure it is possible , So I want to make sure of it :)
The thing is I have a complex type A and another complex type B that only differs from A that its attribute has a fixed value.
example:
<xs:complexType name="A">
<xs:attribute name="AAtrr" type="xs:string"/>
</xs:complexType>
<xs:complexType name="B">
<xs:attribute name="AAtrr" type="xs:string" fixed="Something"/>
</xs:complexType>
This is of course a simplified example, but for start I'm wondering if B can inherit A and just add the Fixed Value for the Attribute.
Upvotes: 0
Views: 1177
Reputation: 6349
Here's one way, with some detail:
<xs:complexType name="A">
<xs:attribute name="AAttr" type="xs:string"/>
</xs:complexType>
<xs:complexType name="B">
<xs:complexContent>
<xs:restriction base="A">
<xs:attribute name="AAttr" type="Restricted"/>
</xs:restriction>
</xs:complexContent>
</xs:complexType>
<xs:simpleType name="Restricted">
<xs:restriction base="xs:string">
<xs:enumeration value="Something"/>
</xs:restriction>
</xs:simpleType>
Upvotes: 2
Reputation: 26006
In XSD you can do that, but B is not an extension of A but a restriction of A.
Upvotes: 0