Reputation: 27
So I have this code snippet over here:
<xs:complexType name="TT1">
<xs:simpleContent>
<xs:extension base="xs:string">
<xs:attribute name="A1" type="xs:integer" use="required"/>
<xs:attribute name="A2" type="xs:integer" use="optional"/>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
<xs:complexType name="TT2">
<xs:simpleContent>
<xs:restriction base="TT1">
<xs:attribute name="A1" use="prohibited"/>
</xs:restriction>
</xs:simpleContent>
</xs:complexType>
and the question is: Is this whole thing valid?
The only thing I see is TT1
:
<xs:extension base="xs:string">
which is nonsensical since the types for A1
and A2
are supposed to be integer.
Is there anything else that I can't see?
P.S. I'm not quite sure about the sense of the use="prohibited" in TT2
but I don't know why.
Upvotes: 1
Views: 925
Reputation: 111491
which is nonsensical since the types for A1 and A2 are supposed to be integer.
No, it's not nonsensical. A1
and A2
are attributes and their types can be defined independently of the type of the content of their associated element (TT1
), a xs:string
.
P.S. I'm not quite sure about the sense of the use="prohibited" in
TT2
but I don't know why.
If this attempted override makes you uneasy, it should. Overriding a required attribute by switching it to being prohibited is not allowed. So, no, this XSD snippet is not valid.
Upvotes: 1