W3C home > Mailing lists > Public > xmlschema-dev@w3.org > December 2001

(unknown charset) extension and restriction

From: (unknown charset) Niko Suave <niko@alum.mit.edu>
Date: Tue, 4 Dec 2001 13:05:47 -0500 (EST)
To: (unknown charset) xmlschema-dev@w3.org
Message-ID: <Pine.LNX.4.21.0112041238010.31520-100000@sub-zero.mit.edu>
I apologize if this has been covered before; the searching function is down
for the mailing lsit archives and my manual scans of the last few months
turned up nothing that looked relevant.

I have some questions about deriving and extending types, and what attributes
are valid.  

I know that an extended type is always the same as the base + some extra;
so, how does that relate to attributes?  Does this mean that an extended
type may not redefine an existing attribute of the base?

For example:
  <xs:complexType name="base">
    <xs:attribute name="name" type="xs:string"/>
    <xs:attribute name="dead" type="xs:boolean"/>
  </xs:complexType>

  <xs:complexType name="extension">
    <xs:complexContent>
      <xs:extension base="base">
	    <xs:attribute name="balance" type="xs:decimal"/>
      </xs:extension>
    </xs:complexContent>
  </xs:complexType>

  <xs:complexType name="extension2">
    <xs:complexContent>
      <xs:extension base="base">
	<xs:sequence>
		<xs:element name="blahblahblah"/>
        </xs:sequence>
	<xs:attribute name="balance" use="prohibited"/>
      </xs:extension>
    </xs:complexContent>
  </xs:complexType>

  <xs:complexType name="extension3">
    <xs:complexContent>
      <xs:extension base="base">
	<xs:sequence>
		<xs:element name="blahblahblah"/>
        </xs:sequence>
	<xs:attribute name="balance" use="required"/>
      </xs:extension>
    </xs:complexContent>
  </xs:complexType>

My gut says that extension2 is clearly invalid (clearly, it
could be implemented as an extension followed by a restriction).
My understanding of the rules (see below) would suggest that the
use="prohibited" clause actually removes the corresponding attribute
use from the list of the class, and therefore the attribute use list
for 'base' is not a subset of the attribute use list for extension2,
and so the extension is not valid.  

If this is correct, then I would like to know how that relates to a wildcard: 
what if you have a prohibited attribute that would otherwise be allowed by a 
wildcard?  Since it seems that Attribute Uses do not include the option of 
something being explicitely prohibited, that attribute would presumably be okay.

I'm not sure about extension3, but the rules would seem to suggest
that it is okay since every attribute use in the base corresponds to
an attribute use in extension3 with the same name, target namesapce, 
and type def but a different {Required} property.  Is this correct?

If that is correct, then the def'n for Complex Content attribute uses is
slighltly confusing, since it makes no mention of what to do about duplicate
attributes like this one.  However, this may be mentioned somewhere else
and, it seems clear that the extended class's desires should take priority.
(see below for def'n of Complex Content Attribute Uses)


thank you for any help
niko



Relevant rules:

extension valid (partial):
1.2 The base type's {attribute uses} must be a subset of the {attribute uses} 
of the complex type definition itself, that is, for every attribute use in 
the {attribute uses} of the {base type definition}, there must be an attribute 
use in the {attribute uses} of the complex type definition itself whose 
{attribute declaration} has the same {name}, {target namespace} and 
{type definition} as its attribute declaration.
1.3 If it has an {attribute wildcard}, the complex type definition must also 
have one, and the base type definition's {attribute wildcard}'s {namespace 
constraint} must be a subset of the complex type definition's {attribute 
wildcard}'s {namespace constraint}, as defined by Wildcard Subset (§3.10.6).


complex content attribute uses:
A union of sets of attribute uses as follows:
1 The set of attribute uses corresponding to the <attribute> [children], if any.
2 The {attribute uses} of the attribute groups ·resolved· to by the ·actual 
value·s of the ref [attribute] of the <attributeGroup> [children], if any.
3 The {attribute uses} of the type definition ·resolved· to by the ·actual 
value· of the base [attribute], unless the <restriction> alternative is 
chosen, in which case some members of that type definition's {attribute uses} 
may not be included, namely those whose {attribute declaration}'s {name} and 
{target namespace} are the same as one of the following:
3.1 The {name} and {target namespace} of the {attribute declaration} of an 
attribute use in the set per clause 1 or clause 2 above;
3.2 what would have been the {name} and {target namespace} of the {attribute 
declaration} of an attribute use in the set per clause 1 above but for the 
·actual value· of the use [attribute] of the relevant <attribute> among the 
[children] of <restriction> being prohibited.
Received on Tuesday, 4 December 2001 13:01:14 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Tuesday, 11 January 2011 00:14:25 GMT