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

Re: XML Schema quiz on default values

From: Daniel Dui <daniel.dui@gmail.com>
Date: Fri, 24 Aug 2012 17:16:25 +0100
Message-ID: <CAACJ0waVrQNG2qT2r2X7XDP8D6zEwv1M7GUyaRjPDfR51F8Kug@mail.gmail.com>
To: "C. M. Sperberg-McQueen" <cmsmcq@blackmesatech.com>
Cc: "Costello, Roger L." <costello@mitre.org>, "xmlschema-dev@w3.org" <xmlschema-dev@w3.org>
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.

The biggest issue that I have found with default values, and why I usually
end up not using them, is that the default value is specified only in the
schema and not in an instance document. So a consumer app that processes
the document in a schema-unaware fashion has no knowledge of the default
value.

Usually I work with in organisation that want to build schema-aware
producers and schema-unaware consumers. If the consumer can't use the
default value, why specify it in the schema?

Another scenario is when there are multiple consumers, some schema-aware
and some schema-unaware. Using default values can introduce
inconsistent behavior across different consumers within the same
organisations.

-daniel



On 24 August 2012 16:56, C. M. Sperberg-McQueen <cmsmcq@blackmesatech.com>wrote:

>
> On Aug 24, 2012, at 6:33 AM, Daniel Dui wrote:
>
> > Roger et al., thanks for the clarification.
> >
> > I have used XML Schema for a long time and this is definitely a dark
> corner of the specs.
> >
> > I always warn people about using default values and often recommend not
> using them. This non-obvious defaulting behavior looks to me like another
> reason why many schemas should avoid using default values.
>
> I'm puzzled.  The behavior "Empty element gets the default"
> seems straightforward enough to me.
>
> Can you clarify in what way you find the behavior non-obvious?
>
> --
> ****************************************************************
> * C. M. Sperberg-McQueen, Black Mesa Technologies LLC
> * http://www.blackmesatech.com
> * http://cmsmcq.com/mib
> * http://balisage.net
> ****************************************************************
>
>
>
>
>


-- 
____________________________________________________________
   Daniel Dui - daniel.dui@gmail.com - skype: danieldui
Received on Friday, 24 August 2012 16:19:23 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Friday, 24 August 2012 16:19:23 GMT