W3C home > Mailing lists > Public > xmlschema-dev@w3.org > February 2005

RE: Default and Fixed Values of attributes

From: Michael Kay <mike@saxonica.com>
Date: Sun, 13 Feb 2005 17:49:51 -0000
To: "'Hans Teijgeler'" <hans.teijgeler@quicknet.nl>, "'XML-Schema Developers Forum'" <xmlschema-dev@w3.org>
Cc: "'Paap, Onno'" <onno.paap@ezzysurf.com>
Message-Id: <E1D0Nse-0006XO-00@ukmail1.eechost.net>
 

  _____  

From: xmlschema-dev-request@w3.org [mailto:xmlschema-dev-request@w3.org] On
Behalf Of Hans Teijgeler
Sent: 13 February 2005 16:38
To: XML-Schema Developers Forum
Cc: Paap, Onno
Subject: Default and Fixed Values of attributes


Ladies and gentlemen,
 
I am struggling with Default and Fixed Values for attributes, and I need
your advice.
 
Assume:
*	complexType A with attribute 'a' 

*	complexType B is typed with A and the inherited attribute 'a' is
restricted by means of a default or fixed value "value1" 

*	complexType C is typed with B and the inherited attribute 'a' has
the inherited default or fixed value "value1" 
 
Now I want to define an other default or fixed value "value2" for inherited
attribute 'a' of complexType C because that value is, in the real world,
different for this subtype. WRONG!!! When I do that (in XMLSpy, latest
version) that "value2" is kind of "inherited backwards" to the inherited
attribute 'a' of complexType B, but not to A (see below) 
 
The rules for "fixed" and "default" are slighly different. For "fixed",
Schema Part 1 secton 3.4.6,  Schema Component Constraint: Derivation Valid
(Restriction, Complex) tells you:
 
 2 For each attribute use (call this R) in the
<http://www.w3.org/TR/xmlschema-1/#ct-attribute_declarations> {attribute
uses} the appropriate case among the following must be true:
2.1 If there is an attribute use in the {attribute
<http://www.w3.org/TR/xmlschema-1/#ct-attribute_declarations> uses} of the
{base type  <http://www.w3.org/TR/xmlschema-1/#ct-base_type_definition>
definition} (call this B) whose {attribute declaration}
<http://www.w3.org/TR/xmlschema-1/#attribute>  has the same {name}
<http://www.w3.org/TR/xmlschema-1/#a-name>  and {target
<http://www.w3.org/TR/xmlschema-1/#a-target_namespace> namespace}, then all
of the following must be true: 
2.1.3 [Definition:]  Let the effective value constraint of an attribute use
be its {value  <http://www.w3.org/TR/xmlschema-1/#au-value_constraint>
constraint}, if present, otherwise its {attribute
<http://www.w3.org/TR/xmlschema-1/#attribute> declaration}'s {value
<http://www.w3.org/TR/xmlschema-1/#a-value_constraint> constraint} . Then
one of the following must be true: 
2.1.3.1 B's  <http://www.w3.org/TR/xmlschema-1/#key-evc> .effective value
constraint. is  <http://www.w3.org/TR/xmlschema-1/#key-null> .absent. or
default.
2.1.3.2 R's  <http://www.w3.org/TR/xmlschema-1/#key-evc> .effective value
constraint. is fixed with the same string as B's. 
 
In other words, if B has a fixed value then R (your C) must have the same
fixed value. That's reasonable: a restricted subtype can only permit values
that are valid for the supertype.
 
On the other hand, if B has a default value there is no rule that R (your C)
must have the same default value.
 
However, there's nothing in the spec corresponding to the "backwards
inheritance" you describe. 
 
 
 
XMLSpy seems to be internally confused 
 
I think this is the nub of your problem. XML Spy is not the most conformant
of schema processors. If you want to use trial and error to find out what
the spec means (and we all need to, occasionally) then use Xerces and XSV:
if they give the same answer, it's almost certainly right.
 
Michael Kay
http://www.saxonica.com/ 
Received on Sunday, 13 February 2005 17:50:03 GMT

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