XML Schema XSD TotalDigits与MaxInclusive

Nat*_*han 8 xml xsd

我使用以下定义运行XML Schema:

<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>
Run Code Online (Sandbox Code Playgroud)

但是,在我看来,这totalDigits是多余的.我对XML Schema有些新意,并希望确保我没有错过任何东西.

什么是实际行为totalDigitsmaxInclusive

可以totalDigits始终与的组合来表示minInclusiveMaxInclusive

如何totalDigits影响负数?

Con*_*oyP 8

totalDigits总是可以用minInclusive和MaxInclusive的组合来表示吗?

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

totalDigits如何影响负数?

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

<xsd:totalDigits>facet 的value属性指定的数字将限制小数点两侧的数字中允许的总位数.