XSD - xs:nonNegativeInteger 和以 .00 结尾的值
我意识到值 0.00 不是一个有效的非负整数,甚至也不是一个整数。 不幸的是,数据是以这种格式出现的。 如果它以 .0 结尾,我不想丢弃它,但是,我也不想将类型更改为 Decimal,并且可能以 .1 结尾的值有效。
有没有办法我的 XSD 可以验证数字,使它们只是正整数,因此 0.00、0、1、1.0、2.0000000 等值都被接受,但 -1、1.1、2.2、3.3333 都是无效的?
谢谢 -C
I realize that the value 0.00 is not a valid nonNegativeInteger, nor is it even an Integer.
Unfortunately, the data is coming in that format. I don't want to throw it away if it ends with .0 but, I also don't want to change the type to Decimal and possibly have values ending in .1 coming in as valid.
Is there a way my XSD can validate numbers such that they are just positive whole numbers, so values of 0.00, 0, 1, 1.0, 2.0000000 etc are all accepted, but -1, 1.1, 2.2, 3.3333 are all invalid?
Thanks
-c
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以考虑更改为十进制并对小数点后的位数进行限制。 特别是,您也许可以使用正则表达式方面。 我从来没有尝试过这个,甚至不知道它是否有效,但这是一个值得关注的方向。 您将限制词法空间而不是值空间,但这就是您想要的。
You could look at changing to decimal and placing a restriction on the places after the decimal point. In particular, you might be able to use a regex facet. I've never tried this, and don't even know if it's valid, but it's a direction to look at. You'd be restricting the lexical space rather than the value space, but that's what you want.
这适合我的需要,谢谢约翰
This works for what I need, thanks John