tags:

views:

55

answers:

3

Hi, 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.

+1  A: 

Is this what you are looking for?

Stack Overflow

dball917
I don't think so, because that example talks about adding options, and I'm talking about restricting inherited ones
ozba
A: 

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

hstoerr
Can you or anyone else use my example to show exactly how? how do I restrict a specific attribute? something like this that I thought of is not valid:<xs:complexType name="B"> <xs:complexContent > <xs:restriction base="A"> <xs:attribute ref="AAttr" fixed="something"></xs:attribute> </xs:restriction> </xs:complexContent> </xs:complexType>
ozba
See the answer of xcut - he was faster. :-)
hstoerr
+1  A: 

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