Re: XML Schema quiz on default values

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 UTC