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

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

From: Michael Kay <mike@saxonica.com>
Date: Fri, 23 Mar 2012 12:08:47 +0000
Message-ID: <4F6C67CF.1020001@saxonica.com>
To: xmlschema-dev@w3.org

> 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.
Except that the XSD spec doesn't have any way of saying that that's what 
it's saying, because it doesn't define semantics for this use case; the 
only semantics defined for the schema is its effect on validation / PSVI 
creation. That means that if XSD allowed this, it would have to say 
"this is allowed but has no recognized meaning".

Now there are in fact plenty of cases where XSD does allow things that 
have no recognized meaning, and there are two schools of thought about 
whether this is good or bad. The debate is generally conducted under the 
name "paternalism": a paternalistic design stops you doing something 
which is apparently pointless but not actively harmful (like creating a 
choice with no members). Another example occurs with facet-based 
restriction, where we prevent you from defining a minInclusive that is 
less than the minInclusive of your base type.

It's hard to get this right consistently. In many cases I think the 
right approach when users do something pointless is a warning (which is 
of course outside the scope of the spec). But should we, for example, 
allow you to specify minInclusive for an xs:QName, given that it will 
have no effect? I think not. And specifying a default for a mandatory 
attribute seems to me to fall into the same category.

Michael Kay
Received on Friday, 23 March 2012 12:09:16 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 23:16:01 UTC