Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: Optional vs. nilable

From: Martin Honnen <mahotrash@-----.-->
To: NULL
Date: 4/1/2009 6:13:00 PM
Miki Peric wrote:
> What is the difference between:
> 
> <element name="DATUM" type="dateTime" minOccurs="0"></element>
> 
> and:
> 
> <element name="DATUM" type="dateTime" nillable="true"></element>

For this you can have
   <DATUM
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
     xsi:nil="true"></DATUM>
in your XML document to indicate the DATUM value is nil (or null in 
database terms).

> Which aproach is better? 


I prefer the nillable/xsi:nil approach as it is clear from the instance 
document alone that there can be a DATUM value but in some cases it is 
nil. If you use minOccurs="0" to indicate there is no DATUM value then 
the instance document does not have any DATUM element but you will need 
to check the schema first to find out the containing element might have 
a DATUM child.

But generally what is better might depend on the tool or API support you 
have, if some XML export/import tool or API supports one but not the 
other then the preference is clear.

> Does it make sense to use both:
> 
> <element name="DATUM" type="dateTime" minOccurs="0" 
> nillable="true"></element>
> 
> ? 

I think the schema language allows that but I have a hard time to come 
up with a use case for doing that.




-- 

	Martin Honnen --- MVP XML
	http://JavaScript.FAQTs.com/


transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent