Reputation: 317
I am trying to understand why some XSD tools (Oxygen) accept the following definition but others (notably XMLspy) do not:
<xs:complexType mixed="true" name="al_complextype">
<xs:complexContent>
<xs:extension base="block_maximaal">
<xs:attributeGroup ref="agroup"/>
</xs:extension>
</xs:complexContent>
</xs:complexType>
<xs:complexType name="block_maximaal" mixed="true">
<xs:attributeGroup ref="agroup"/>
</xs:complexType>
<xs:attributeGroup name="agroup">
<xs:attribute name="property"/>
</xs:attributeGroup>
Issue seems to be that attribute property is used twice, once from base complexType and once from extending class.
I know that XML Schema is notorious for edge cases, but was wondering if someone can point me to the relevant section in the Schema specification where this is discussed. I find it hard to read :-(
Upvotes: 0
Views: 323
Reputation: 163262
Saxon reports:
Error on line 5 of test.xsd:
Attribute @property appears more than once in attribute group
Schema processing failed: The schema is invalid
Finding the rule that prohibits this is, as you point out, a nightmare. Go to section 3.4.2 XML Representation of Complex Type Definitions, and within that the subsection headed "Complex Type Definition with complex content Schema Component". Within this is a row identifed as "{attribute uses}. This indicates that the {attribute uses} is the union of the attributes defined in the attribute group defined on the base type and the attributes in the attribute group defined on the extension. If this union contains two attributes with the same name, then it's definitely invalid.
But, you can argue that a union should eliminate duplicates, in which case you get into a discussion about whether and when two attribute use components are identical, and the spec itself admits that it has no answer to this question (§3.4.6: "...a notion of component identity which is only incompletely defined by this version of this specification"). In this case you've got two references to the same attribute group and so there is certainly a case to be made that the attribute groups, and therefore the attribute uses they contain, are identical, in which case duplicates are eliminated.
So I think in this case both interpretations are legitimate.
Upvotes: 2