XML模式XSD TotalDigits与MaxInclusive

时间:2020-03-06 15:05:29  来源:igfitidea点击:

我已经遍历了具有以下定义的XML模式:

<xs:simpleType name="ClassRankType">
    <xs:restriction base="xs:integer">
        <xs:totalDigits value="4"/>
        <xs:minInclusive value="1"/>
        <xs:maxInclusive value="9999"/>
    </xs:restriction>
</xs:simpleType>

但是,在我看来," totalDigits"是多余的。我是XML Schema的新手,并希望确保我没有错过任何内容。

" totalDigits"和" maxInclusive"的实际行为是什么?

总数字总能用minInclusive和MaxInclusive的组合来表示吗?

" totalDigits"如何影响负数?

解决方案

can totalDigits always be represented with a combination of minInclusive and MaxInclusive?

在这种情况下,可以。当我们处理整数时,该值必须是整数,因此我们在minInclusive和maxInclusive之间有一组有限的值。如果我们有十进制值,totalDigits会告诉我们该值总共可以有多少个数字。

How does totalDigits affect negative numbers?

它是数字中允许的总位数,不受小数点,减号等的影响。来自auxy.com:

The number specified by the value attribute of the <xsd:totalDigits> facet will restrict the total number of digits that are allowed in the number, on both sides of the decimal point.

totalDigits是该数字可以包含的总位数,包括十进制数字。因此,totalDigits为4将允许4.345或者65.43或者932.1或者4位数的整数,如上例所示。否定也一样。这些先前示例中的任何一个都可以设为负数,并且仍然可以验证为totalDigits为4.

最大值和最小值(含/不含)限制数字的范围。在示例中,最大包含似乎有点多余,但是最小包含确定该数字大于0。