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

Re: Codelists: restricting simpleContent complexTypes

From: Jeni Tennison <jeni@jenitennison.com>
Date: Wed, 16 Oct 2002 13:31:18 +0100
Message-ID: <34531069707.20021016133118@jenitennison.com>
To: xmlschema-dev@w3.org, Stefan Wachter <Stefan.Wachter@gmx.de>

Hi Stefan,

> PS: Is it allowed to first prohibit an attribute and to introduce it
> again later? The spec. says that attribute declarations with
> use="prohibited" are nothing at all. This suggests that a type does
> not know if an attribute is prohibited or simply not present.
> Therefore adding an attribute after it was prohibited should be
> allowed. Sounds strange, doesn't it?

Well, I *think* that you're not allowed to add back a prohibited
attribute. Clause 1.5 of Schema Component Constraint: Derivation Valid
(Extension) [1] says:

  1.5 It must in principle be possible to derive the complex type
      definition in two steps, the first an extension and the second a
      restriction (possibly vacuous), from that type definition among
      its ancestors whose {base type definition} is the ·ur-type

      NOTE: This requirement ensures that nothing removed by a
      restriction is subsequently added back by an extension. It is
      trivial to check if the extension in question is the only
      extension in its derivation, or if there are no restrictions bar
      the first from the ·ur-type definition·.

The NOTE implies that you shouldn't be able to prohibit an attribute
and then introduce it again later, but I've never been able to work
out how the clause actually guarantees that. For example, if I did:

<xs:complexType name="T1">
  <xs:sequence />

<xs:complexType name="T2">
  <xs:extension base="T1">
    <xs:attribute name="foo" />

<xs:complexType name="T3">
  <xs:restriction base="T2">
    <xs:attribute name="foo" use="prohibited" />

<xs:complexType name="T4">
  <xs:extension base="T3">
    <xs:attribute name="foo" />

then I can derive T4 in two steps from T1 (the type amongst T4's
ancestors whose base type definition is the ur-type definition), first
an extension:

<xs:complexType name="_T4">
  <xs:extension base="T1">
    <xs:attribute name="foo" />

and then a restriction:

<xs:complexType name="T4">
  <xs:restriction base="_T4" />

I think that the intention is that the intermediate type definition is
constructed according to the instructions:

  Constructing the intermediate type definition to check this
  constraint is straightforward: simply re-order the derivation to put
  all the extension steps first, then collapse them into a single
  extension. If the resulting definition can be the basis for a valid
  restriction to the desired definition, the constraint is satisfied.

in which case the intermediate definition would be:

<xs:complexType name="_T4">
  <xs:extension base="T1">
    <xs:attribute name="foo" />
    <xs:attribute name="foo" />

which wouldn't be allowed because it has two attribute uses for the
same attribute, and which would therefore mean that T4 wasn't a valid
extension of T3.



[1] http://www.w3.org/TR/xmlschema-1/#cos-ct-extends

Jeni Tennison
Received on Wednesday, 16 October 2002 08:31:20 UTC

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