RE: Default and Fixed Values of attributes

If the base type makes the attribute "required", that means the attribute
must be present in every instance of the type. You can't make it optional in
a subtype, because if you did, it would allow instances of the derived type
to be invalid against the base type. And if it's not optional, there's no
sense in having a default value.
 
Michael Kay
http://www.saxonica.com/

  _____  

From: Hans Teijgeler [mailto:hans.teijgeler@quicknet.nl] 
Sent: 14 February 2005 14:04
To: XML-Schema Developers Forum
Cc: Michael Kay; Paap, Onno
Subject: FW: Default and Fixed Values of attributes


Dear Michael,
 
I downloaded Stylus Studio's XML Editor and validated the same file, and
also had the same Catch 22 when a Default value is entered:
*	the use MUST be consistent with the base type 

*	since the base type attribute has use="required" I changed that back
to that, BUT: 

*	then I get the error message: "If default and use are both present,
use must have the value 'optional' "
 
Can you or someone else help me to get out of this booby trap?
 
Regards,
Hans
 
-----Original Message-----
From: xmlschema-dev-request@w3.org [mailto:xmlschema-dev-request@w3.org] On
Behalf Of Hans Teijgeler
Sent: Monday, February 14, 2005 12:38 PM
To: 'Michael Kay'; 'XML-Schema Developers Forum'
Cc: 'Paap, Onno'
Subject: RE: Default and Fixed Values of attributes


Dear Michael,
 
Thanks for your blazingly fast response, written on a Sundaynight! It gives
some clues for further digging.
 
1)   In 2.1 it says that the stuff in 2.1.3 must be true IF B is in the same
target namespace as R. That is interesting. What if the schema that defines
R is imported in the schema that defines B?
 
2)   I would be obliged to receive your reaction on the other questions in
my message, viz:
*         Whether or not the definition of a default or fixed value should
have as a consequence that the use constraint should become "optional" (for
default values) or even should be removed at all (for fixed values). 
*         Can you explain the rationale for the split between
specialization(typing)_by_extension and specialization_by_restriction? From
a data modelling point of view that is illogical, because adding an
attribute or child element also constitutes an extra constraint, and besides
that it is highly inconvenient and causes a lot of hassle.
 
Kind regards,
Hans
 
============================================================================
===========================================
 
-----Original Message-----
From: xmlschema-dev-request@w3.org [mailto:xmlschema-dev-request@w3.org] On
Behalf Of Michael Kay
Sent: Sunday, February 13, 2005 6:50 PM
To: 'Hans Teijgeler'; 'XML-Schema Developers Forum'
Cc: 'Paap, Onno'
Subject: RE: Default and Fixed Values of attributes
 

  _____  

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:
1. complexType A with attribute 'a' 
2. complexType B is typed with A and the inherited attribute 'a' is
restricted by means of a default or fixed value "value1" 
3. 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
<http://www.w3.org/TR/xmlschema-1/#attribute> declaration} 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 Monday, 14 February 2005 14:19:28 UTC