0

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.

ozba
  • 6,522
  • 4
  • 33
  • 40

2 Answers2

2

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>
xcut
  • 6,219
  • 1
  • 33
  • 27
0

In XSD you can do that, but B is not an extension of A but a restriction of A.

Dr. Hans-Peter Störr
  • 25,298
  • 30
  • 102
  • 139