Notice that we did not provide the "date" content for "shipDate" as required by the schema.
But we specified the special attribute "xsi:nil="true"" to override the "shipDateType" definition.
order_nil.xml will pass the schema validation too:
Test 3. But if you don't follow those rules mentioned in the previous section, you will get validation errors.
Here is a sample XML document, order_nil_error.xml, that uses "xsi:nil" incorrectly:
>java XsdSchemaValidator order.xsd order_nil_error.xml
Error:
Line number: 4
Column number: 25
Message: cvc-elt.3.1: Attribute
'http://www.w3.org/2001/XMLSchema-instance,nil' must not appear
on element 'price', because the {nillable} property of 'price'
is false.
Error:
Line number: 5
Column number: 64
Message: cvc-elt.3.2.1: Element 'shipDate' cannot have character
or element information [children], because
'http://www.w3.org/2001/XMLSchema-instance,nil' is specified.
Failed with errors: 2