gpt4 book ai didi

xsd - XSD 中禁止的原始数据类型的空元素

转载 作者:行者123 更新时间:2023-12-04 06:34:01 31 4
gpt4 key购买 nike

我在处理 Web 服务响应时遇到了 Apache CXF 解析错误。归结为一个空元素被返回:

<myValue />

元素定义如下:
<xsd:element name="myValue" type="xsd:float" minOccurs="0">

现在我在 CXF 邮件列表上看到了 empty value is not allowed by the XSD-spec :

Well, there isn't a workaround for this as it's not a bug. An empty element is not valid for any Decimal or Date type or anything like that.
Thus, it SHOULD throw an exception.
What are you expecting it to do?



现在问题来了:我在 XML Schema 规范中究竟在哪里可以找到这个约束?

最佳答案

Where exactly can I find this constraint in the XML Schema specification?



http://www.w3.org/TR/xmlschema-2/#float-lexical-representation

float values have a lexical representation consisting of a mantissa followed, optionally, by the character "E" or "e", followed by an exponent.
...
The representations for exponent and mantissa must follow the lexical rules for integer and decimal.
...
The special values positive and negative infinity and not-a-number have lexical representations INF, -INF and NaN, respectively.



所以 xs:float至少需要一个尾数是 xs:decimal ...

decimal has a lexical representation consisting of a finite-length sequence of decimal digits (#x30-#x39) separated by a period as a decimal indicator. An optional leading sign is allowed.



...并且空字符串不是有效的 xs:decimal .

如果您没有此元素的值,则应尽可能不包含此元素。您的架构似乎允许省略此元素,因为 minOccurs有值 0 .其他解决方案是插入合适的替换值,例如 0NaN .

关于xsd - XSD 中禁止的原始数据类型的空元素,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5043496/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com