XSD 验证失败,因为 null 值是无效的十进制
我在编写有效的 XSD 来描述小数的潜在空值时遇到问题。
我正在尝试验证以下 XML
<RatioDe fieldId="011" nil="true"></RatioDe>
,并且该元素的相应 XSD 描述是
<xs:element minOccurs="0" maxOccurs="1" name="RatioDe" nillable="true">
<xs:complexType>
<xs:simpleContent>
<xs:extension base="xs:decimal">
<xs:attribute name="fieldId" type="xs:string" />
<xs:attribute name="nil" type="xs:boolean" />
</xs:extension>
</xs:simpleContent>
</xs:complexType>
</xs:element>
基本上,错误消息是
元素 'RatioDe' 无效 - 值 '' 不是有效的 'Decimal' -- 字符串 '' 不是有效的十进制值
目前我不知道如何更改我的 xsd 以使 xml 有效。
i have a problem writing a valid XSD which describes a potential null-value for a decimal.
I'm trying to validate following XML
<RatioDe fieldId="011" nil="true"></RatioDe>
and the corresponding XSD description for this element is
<xs:element minOccurs="0" maxOccurs="1" name="RatioDe" nillable="true">
<xs:complexType>
<xs:simpleContent>
<xs:extension base="xs:decimal">
<xs:attribute name="fieldId" type="xs:string" />
<xs:attribute name="nil" type="xs:boolean" />
</xs:extension>
</xs:simpleContent>
</xs:complexType>
</xs:element>
Basically, the errormessage is
The element 'RatioDe' is invalid - The value '' is not a valid 'Decimal' -- The string '' is not a valid decimal value
At the moment i have no further idea what to change in my xsd to make the xml valid.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您需要在实例文档中使用
xsi:nil
,而不仅仅是nil
,即并确保
xsi
前缀在文档(带有xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
)You need to use
xsi:nil
in your instance document, not justnil
, i.e.And make sure that the
xsi
prefix is defined somewhere in the document (withxmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
)