XSD attribute NILLABLE not working

非 Y 不嫁゛ 提交于 2019-12-05 02:36:39

A node like < HarvPop>< /HarvPop> is stating that the value is there and that it's value is an empty string.

Based on the information on this w3.org page: http://www.w3.org/TR/xmlschema-0/#Nils

The nillable attribute is used like this:

Definition: <xsd:element name="shipDate" type="xsd:date" nillable="true"/>

Usage: <shipDate xsi:nil="true"></shipDate>

ie You have to specifically state that the value is null.

The other way to do it is to state minoccurs = 0, to allow the value to be missing.

sublimeike

One way that I found that also fixes the problem with minimal code was to add the default="0" attribute to the XSD. This allows you to validate as a double without having to deal with nil by making nil default to a number.

Error deserialising XML document with strongly typed XSD

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!