XML/XSD: xs:date and nillable
If I allow a nillable date element like this
Code:
<xs:element name="DOB" type="xs:date" nillable="true"/>
how can I write my element so it validates when there is no date - e.g. You don't know the DOB (date of birth)
Using XmlSpy to test, will need to validate with .NET.
I've tried an empty element, "0000-00-00", and just not including the element, nothing works so far.
Re: XML/XSD: xs:date and nillable
From the standard:
Quote:
If {nillable} is true, then an element may also be ·valid· if it carries the namespace qualified attribute with [local name] nil from namespace
http://www.w3.org/2001/XMLSchema-instance and value true (see xsi:nil (§2.6.2)) even if it has no text or element content despite a {content type} which would otherwise require content. Formal details of element ·validation· are described in Element Locally Valid (Element) (§3.3.4).
Therefore, given that xsi is the namespace prefix of XMLSchema-instance, the element would look like
<DOB xsi:nil="true"/>
Re: XML/XSD: xs:date and nillable