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

This should cover W3C XML Schema, Relax NG and DTD related problems.
javab0y
Posts: 2
Joined: Fri Feb 05, 2010 6:00 am

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

Post 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?
sorin_ristache
Posts: 4141
Joined: Fri Mar 28, 2003 2:12 pm

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

Post 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
javab0y
Posts: 2
Joined: Fri Feb 05, 2010 6:00 am

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

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