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: Thu, 23 Aug 2012 18:55:05 -0600
Cc: "C. M. Sperberg-McQueen" <cmsmcq@blackmesatech.com>, "xmlschema-dev@w3.org" <xmlschema-dev@w3.org>
Message-Id: <E912F7E0-0056-4500-B386-D31C0A350473@blackmesatech.com>
To: "Costello, Roger L." <costello@mitre.org>

On Aug 23, 2012, at 3:47 PM, Costello, Roger L. wrote:

> Hello Folks,
> 
> Recall that when you declare an element (or attribute) you can give it a default value.
> ...
> 
> Let's take another example. Here I declare the Title element to be of type string and give it a default value, "Hello World":
> 
> 	<xs:element name="Title" type="xs:string" default="Hello World" />
> 
> Now in my instance document I create an empty Title element:
> 
> 	<Title></Title>
> 
> Quiz: What is the value of Title?...

> Answer: the value of Title is the empty string, not the default value. The reason is that the empty string is a valid value of the string data type. If you want Title to have the default value then you must explicitly enter the default value:
> 
> 	<Title>Hello World</Title>



Why do you believe this?

-- 
****************************************************************
* 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 00:55:31 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Friday, 24 August 2012 00:55:31 GMT