创建带有限制的 XSD 可选十进制元素 [英] Create an XSD optional decimal element with restrictions
本文介绍了创建带有限制的 XSD 可选十进制元素的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我设法使用这个创建了一个可选的十进制元素:
I've managed to create an optional decimal element using this:
<xs:simpleType name="OptionalDecimal">
<xs:union memberTypes="xs:decimal empty-string" />
</xs:simpleType>
但我还需要添加限制,以便如果已输入,例如将其限制为最大长度为 10 和最多 3 个小数位.所以我有这个:
but I also need to add restrictions so that if it has been entered, to limit it to a maximum length of 10 and maximum number of 3 decimal places for example. So I've got this:
<xs:restriction base="xs:decimal">
<xs:maxInclusive value="9999999999"/>
<xs:fractionDigits value="3"/>
</xs:restriction>
问题是我不知道如何组合它们.它们可以合并吗?或者有更好的方法吗?
The problem is I don't know how to combine them. Can they be combined? Or is there a better way of doing this?
推荐答案
感谢 Kevin 的建议,我想出了这个解决方案:
Thanks to Kevin's suggestion I've come up with this which does the trick:
<xs:simpleType name="Decimal10-2">
<xs:restriction base="xs:decimal">
<xs:maxInclusive value="9999999999"/>
<xs:fractionDigits value="2"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="OptionalDecimal10-2">
<xs:union memberTypes="Decimal10-2 empty-string" />
</xs:simpleType>
这篇关于创建带有限制的 XSD 可选十进制元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文