- From: Jeni Tennison <jeni@jenitennison.com>
- Date: Sat, 27 Apr 2002 10:23:47 +0100
- To: Tom Moog <tmoog@sarvega.com>
- CC: xmlschema-dev@w3.org
Hi Tom, > Both MSV -strict and SQC accept the following complex types, but I > don't understand why attribute A2 can be required in a base type, > and prohibited in a derived type, and still satisfy the requirement > that > > all derived types should be compatible with the base type. > > Obviously, I'm missing something. It's a little weird, but basically use="prohibited" only has an effect if you use it within a restriction. When you have use="prohibited" on an attribute declaration elsewhere, such as within an extension, the xs:attribute element doesn't actually correspond to anything -- it's effectively ignored. In other words, you might think that you're prohibiting the attribute in the extension, but actually you're not doing anything. Your derived type is equivalent to: <xsd:complexType name="derived"> <xsd:complexContent> <xsd:extension base="base" /> </xsd:complexContent> </xsd:complexType> And any elements of the derived type can have A2 attributes on them. > P.S. Replacing "extension" with "restriction" in the derived type > doesn't make any difference: both processors still accept it. Sure, but in the restriction case, where you actually remove the A2 attribute, an instance that has an A2 attribute is invalid, whereas in the extension case it's valid. I guess that attribute declarations with use="prohibited" should be explicitly banned from within xs:extension to prevent this misunderstanding. Cheers, Jeni --- Jeni Tennison http://www.jenitennison.com/
Received on Saturday, 27 April 2002 05:23:49 UTC