Altova Mailing List Archives>Archive Index >microsoft.public.xml Archive Home >Recent entries >Thread Prev - Optional vs. nilable [Thread Next] Re: Optional vs. nilableTo: 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/
| ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
