C
craig.wagner
I have an element in my schema defined as follows:
<xs:element name="BillingDate" type="xs:dateTime" nillable="true"
minOccurs="0"/>
I use the schema to validate incoming documents using an
XmlValidatingReader in .NET 1.1.
If the document contains the above element with no data, for example:
<BillingDate></BillingDate>
<BillingDate/>
The validation throws an exception on this element telling me it
contains data that doesn't conform to the type. That kind of makes
sense, because the value in the above case is an empty string, and
that's not a valid date.
I can change the above tags to one of the following and then it passes
validation:
<BillingDate xsi:nil="true"></BillingDate>
<BillingDate xsi:nil="true"/>
I can also get rid of the element completely and it passes validation
(because minOccurs="0").
However, I would prefer to not have to go through every document
looking for empty tags and adding the xsi:nil="true" attribute or
removing them from the document.
The same thing happens with elements defined as numeric types (e.g.
xs:int).
Is there any way (other than the above identified solutions) to get the
validation process to pass these elements without an exception?
<xs:element name="BillingDate" type="xs:dateTime" nillable="true"
minOccurs="0"/>
I use the schema to validate incoming documents using an
XmlValidatingReader in .NET 1.1.
If the document contains the above element with no data, for example:
<BillingDate></BillingDate>
<BillingDate/>
The validation throws an exception on this element telling me it
contains data that doesn't conform to the type. That kind of makes
sense, because the value in the above case is an empty string, and
that's not a valid date.
I can change the above tags to one of the following and then it passes
validation:
<BillingDate xsi:nil="true"></BillingDate>
<BillingDate xsi:nil="true"/>
I can also get rid of the element completely and it passes validation
(because minOccurs="0").
However, I would prefer to not have to go through every document
looking for empty tags and adding the xsi:nil="true" attribute or
removing them from the document.
The same thing happens with elements defined as numeric types (e.g.
xs:int).
Is there any way (other than the above identified solutions) to get the
validation process to pass these elements without an exception?