W3C home > Mailing lists > Public > xmlschema-dev@w3.org > March 2012

Re: If attribute default present, 'use' must be optional

From: Pete Cordell <petexmldev@codalogic.com>
Date: Fri, 23 Mar 2012 11:18:33 -0000
Message-ID: <70017720FF9947609890CA398F5E8865@codalogic>
To: <xmlschema-dev@w3.org>, "G. Ken Holman" <gkholman@CraneSoftwrights.com>
Original Message From: "G. Ken Holman"

At 2012-03-23 10:53 +0000, Pete Cordell wrote:
> >Just curious...
> >
> >why in XSD section 3.2.3 Constraints on XML Representations of Attribute 
> >Declarations, Schema Representation Constraint: Attribute Declaration 
> >Representation OK (http://www.w3.org/TR/xmlschema11-1/#sec-src-attdecl) 
> >does it say:
> >
> >    2 If default and use are both present, use must have the ·actual 
> > value· optional
> >
> >Why can't a schema designer choose to have a mandatory attribute with a 
> >default value?
>
> What would a default value mean if it never, ever, gets used because the 
> instance *always* overrides it?
>
> Would that not be misleading to someone?  Either the schema writer or the 
> user or both?


I think a mandatory attribute with a default is telling an XML creator that 
if they don't have a specific value for this field then they should set it 
to the default value.  This can help the consumer of the XML because they 
don't need to be so schema aware and know about default values.  Equally, 
the human reading the XML doesn't need to be so aware of the schema either. 
It can also act as a very useful form of documentation to the human schema 
users.

It seems the current rule is too SQL schema (or similar) derived.  And IMO 
it also attempts to dictate 'common sense', but because the authors are not 
omnipotent, may not be common sense it all situations that it could be 
useful.  Hence it decreases the usefulness of XSD while increasing its 
complexity.

Pete Cordell
Codalogic Ltd
Interface XML to C++ the easy way using C++ XML
data binding to convert XSD schemas to C++ classes.
Visit http://codalogic.com/lmx/ or http://www.xml2cpp.com
for more info
Received on Friday, 23 March 2012 11:17:08 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Friday, 23 March 2012 11:17:09 GMT