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

This should cover W3C XML Schema, Relax NG and DTD related problems.
Posts: 2

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

Fri Feb 05, 2010 6:14 am

I have an element declaration that looks like this:

Code: Select all

 <xsd:complexType name="ConsumerComment">
     <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"/>

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:action xmlns:xsi="" xsi:nil="true"/>

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?
Posts: 4144

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

Fri Feb 05, 2010 6:58 pm


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

Posts: 2

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

Sat Feb 06, 2010 12:03 pm

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.

Return to “XML Schemas”

Who is online

Users browsing this forum: No registered users and 2 guests