D
Dietmar Gräbner
Hi
Right now I'm dealing with derivation by restriction and I have some
questions concerning the attribute property use in context of the
derivation.
Consider following Schema:
<xs:schema elementFormDefault="qualified" attributeFormDefault="unqualified"
xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:complexType name="baseT">
<xs:attribute name="att" use="prohibited"/>
</xs:complexType>
<xs:complexType name="restrictedT">
<xs:complexContent>
<xs:restriction base="baseT">
<xs:attribute name="att" use="required"/>
</xs:restriction>
</xs:complexContent>
</xs:complexType>
</xs:schema>
<xs:element name="b" type="baseT"/>
<xs:element name="restr" type="restrictedT"/>
and the valid instance document:
<b att="strange" xsi:type="restrictedT"/>
The strange thing about this schema is the overriding of the Attribute "att"
and setting the attribute use="require". For the intance Document and its
Element "b" this definition means that by using type substitution (with
xsi:type) the attribute required and not prohibited as defined in the base
type. You can see this rather as a type extension instead of a restriction.
The "XML-Schema Part 1: Structures" permits this behaviour. (as I understood
it) The only combination that is not valid is changing a required attribute
to prohibited or optional.
As a validator I used xsv.
my question:
Whats the reason for this sample to be valid?
Perhaps I misunderstood the sense of use="prohibited"?
thx
Helmut
Right now I'm dealing with derivation by restriction and I have some
questions concerning the attribute property use in context of the
derivation.
Consider following Schema:
<xs:schema elementFormDefault="qualified" attributeFormDefault="unqualified"
xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:complexType name="baseT">
<xs:attribute name="att" use="prohibited"/>
</xs:complexType>
<xs:complexType name="restrictedT">
<xs:complexContent>
<xs:restriction base="baseT">
<xs:attribute name="att" use="required"/>
</xs:restriction>
</xs:complexContent>
</xs:complexType>
</xs:schema>
<xs:element name="b" type="baseT"/>
<xs:element name="restr" type="restrictedT"/>
and the valid instance document:
<b att="strange" xsi:type="restrictedT"/>
The strange thing about this schema is the overriding of the Attribute "att"
and setting the attribute use="require". For the intance Document and its
Element "b" this definition means that by using type substitution (with
xsi:type) the attribute required and not prohibited as defined in the base
type. You can see this rather as a type extension instead of a restriction.
The "XML-Schema Part 1: Structures" permits this behaviour. (as I understood
it) The only combination that is not valid is changing a required attribute
to prohibited or optional.
As a validator I used xsv.
my question:
Whats the reason for this sample to be valid?
Perhaps I misunderstood the sense of use="prohibited"?
thx
Helmut