Re: XML Schema quiz on default values

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