Page 1 of 1

nillable="false" and xsi:nil="true" validation

Posted: Fri Feb 05, 2010 6:14 am
by javab0y
I have an element declaration that looks like this:

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>
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.

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>
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?

Re: nillable="false" and xsi:nil="true" validation

Posted: Fri Feb 05, 2010 6:58 pm
by sorin_ristache
Hello,

In what Oxygen version can you validate that XML snippet without validation errors? I get the following error which is obviously the expected one:

Code: Select all

Attribute 'http://www.w3.org/2001/XMLSchema-instance,nil' must not appear on element 'action', because the {nillable} property of 'action' is false.
Can you post some short (but complete) sample files for reproducing the problem, that is for validating an XML instance containing an action with xsi:nil attribute without errors against an XML Schema that specifies nillable="false" for the action element?


Regards,
Sorin

Re: nillable="false" and xsi:nil="true" validation

Posted: Sat Feb 06, 2010 12:03 pm
by javab0y
Ok thanks for the reply.

When I tried to create a cut down (short) sample file to post for you, I found that this indeed was giving me the error that you were getting.

So it was working... in this case. It still does not work for my original issue.

My real world problem (which is a much bigger schema) must have some definition that is incorrect I assume? I will check rule out first I think instead of wasting your time with it. Unless it is a size/complexity thing with Oxygen...

Thanks for your help so far. Will let you know if I still have an issue.