W3C home > Mailing lists > Public > xmlschema-dev@w3.org > April 2002

Re: attribute required in base type/prohibited in derived type

From: Jeni Tennison <jeni@jenitennison.com>
Date: Sat, 27 Apr 2002 10:23:47 +0100
Message-ID: <63433990805.20020427102347@jenitennison.com>
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:extension base="base" />

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



Jeni Tennison
Received on Saturday, 27 April 2002 05:23:49 UTC

This archive was generated by hypermail 2.3.1 : Wednesday, 7 January 2015 14:55:56 UTC