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

Re: XML Schema quiz on default values

From: C. M. Sperberg-McQueen <cmsmcq@blackmesatech.com>
Date: Fri, 24 Aug 2012 11:21:42 -0600
Cc: "C. M. Sperberg-McQueen" <cmsmcq@blackmesatech.com>, "Daniel Dui" <daniel.dui@gmail.com>, "Costello, Roger L." <costello@mitre.org>, <xmlschema-dev@w3.org>
Message-Id: <0C6BA7EF-0BAD-4F0A-9CD4-E6BDDFAB733F@blackmesatech.com>
To: "Pete Cordell" <petexmldev@codalogic.com>

On Aug 24, 2012, at 11:03 AM, Pete Cordell wrote:

> Original Message From: "Daniel Dui"
>> My experience is that a user that sees the default feature in XML schema
>> expects that the default value is the value that an optional element
>> "takes" when it's not included in the instance document.
>> You might think it's naive, but that's the reality for many C++/Java/C#
>> developers who need to deal with XML from time to time. It's not, I hope,
>> for XML specialists.
> I agree.  And to make things even more confusing, that's the behaviour for attributes I believe.

When things don't have an order, it's easy to supply a default value
for them when they don't appear in the surface syntax.  

But consider the content model (a | b | c | d)*, where a and b
have default values.  Suppose the parent turns up with no children.
We want default values for elements to be supplied on the same
lines as for attributes, so we want default values for a and b to
be supplied here.

In which order?

And how many of them?

These questions are trivial for relational databases (order is not
an issue and you get exactly one) and for attributes (ditto and ditto).
For elements, they don't seem to me to have answers.  So 
the reason element defaults don't work the same as attribute
defaults is, essentially, that they can't because unlike attributes
elements have position and cardinality. 

* C. M. Sperberg-McQueen, Black Mesa Technologies LLC
* http://www.blackmesatech.com 
* http://cmsmcq.com/mib                 
* http://balisage.net
Received on Friday, 24 August 2012 17:22:11 UTC

This archive was generated by hypermail 2.3.1 : Wednesday, 7 January 2015 14:56:20 UTC