nillable="false" and xsi:nil="true" validation
Posted: Fri Feb 05, 2010 6:14 am
I have an element declaration that looks like this:
In particular if you notice the action element declaration has nillable="false".
When I try to validate, the following XML snippet in Oxygen - using External Validation by associating the relevant schema with the XML document, the validation is successful.
In particular if you notice the action element attribute value has xsi:nil="true".
Should this be the case? Surely if nillable="false", then setting xsi:nil="true" on that element should throw a schema validation error?
Code: Select all
<xsd:complexType name="ConsumerComment">
<xsd:sequence>
<xsd:element name="commentTypeCode" nillable="false" type="xsd:string"/>
<xsd:element name="action" nillable="false" type="xsd:string"/>
<xsd:element name="commentEndDate" nillable="true" type="xsd:dateTime"/>
</xsd:sequence>
</xsd:complexType>
When I try to validate, the following XML snippet in Oxygen - using External Validation by associating the relevant schema with the XML document, the validation is successful.
Code: Select all
<ns1:commentTypeCode>type</ns1:commentTypeCode>
<ns1:action xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true"/>
<ns1:commentEndDate>2006-05-04T18:13:51.0Z</ns1:commentEndDate>
Should this be the case? Surely if nillable="false", then setting xsi:nil="true" on that element should throw a schema validation error?