W3C home > Mailing lists > Public > xmlschema-dev@w3.org > May 2009

RE: "redefine" attribute allowed when deriving by extension?

From: Michael Kay <mike@saxonica.com>
Date: Fri, 22 May 2009 09:18:12 +0100
To: "'Gert Driesen'" <gert.driesen@telenet.be>, <xmlschema-dev@w3.org>
Message-ID: <391226D5330D4698B43B6699D46A7AB3@Sealion>
Saxon gives the error message:

Error on line 8 of test.xsd:
  Attribute @name appears more than once in attribute group
Schema processing failed: The schema is invalid

The property tableau for complex types says that {attribute uses} for the
extended type is the union of the attribute uses listed in the <attribute>
children and the {attribute uses} of the type definition identified by the
base attribute. So there are two attribute uses with the same name, which
violates clause 4 of Schema Component Constraint: Complex Type Definition
Properties Correct ("Two distinct attribute declarations in the {attribute
uses} must not have identical {name}s and {target namespace}s"). 

There's some wriggle room over the term "union". If two attribute uses are
the same in all respects, then one could argue that forming the union
eliminates the duplicates. The specification explicitly says that it doesn't
define what it means for two schema components to be identical, and some
people interpret it in terms of all the properties being the same. However,
one can't claim they are identical if one says "optional" and the other says


Michael Kay

> -----Original Message-----
> From: xmlschema-dev-request@w3.org 
> [mailto:xmlschema-dev-request@w3.org] On Behalf Of Gert Driesen
> Sent: 21 May 2009 10:42
> To: xmlschema-dev@w3.org
> Subject: "redefine" attribute allowed when deriving by extension?
> Hi,
> I'm sorry if this has been answered before (or if the answer 
> should've been obvious), but can someone tell me if the 
> following XML Schema should be considered valid:
> <xs:schema xmlns="foo" xmlns:xs="http://www.w3.org/2001/XMLSchema"
> targetNamespace="foo" id="foo">
> 	<xs:element name="Foo" type="FooType" />
> 	<xs:element name="Bar" type="BarType" />
> 	<xs:complexType name="FooType">
> 		<xs:attribute name="name" type="xs:string" 
> use="optional"/>
> 	</xs:complexType>
> 	<xs:complexType name="BarType">
> 		<xs:complexContent>
> 			<xs:extension base="FooType">
> 				<xs:attribute name="name" 
> type="xs:string"
> use="required"/>
> 			</xs:extension>
> 		</xs:complexContent>
> 	</xs:complexType>
> </xs:schema>
> Is it allowed to override/redefine an attribute of a base 
> type when deriving by extension?
> The reason I'm asking this is because I've noticed that 
> several implementations expose a different behavior here:
> Altova XML Spy 2009:
> Does not allow attribute to be "redefined" in the derived type.
> Mono:
> Allows attribute to be "redefined" if its use and type match 
> the attribute in the base type.
> Microsoft .NET:
> Allows attribute to be "redefined".
> Oracle Service Bus:
> Allows attribute to be "redefined".
> Any feedback is appreciated.
> Gert
Received on Friday, 22 May 2009 08:18:50 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 23:15:51 UTC