XML Schema XSD total数字vs. max包容性。

时间:2023-01-14 08:49:20

I have run across an XML Schema with the following definition:

我遇到了一个具有以下定义的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>

However, it seems to me that totalDigits is redundant. I am somewhat new to XML Schema, and want to make sure I'm not missing something.

然而,在我看来,total位数是多余的。我对XML模式有点陌生,希望确保没有漏掉什么。

What is the actual behavior of totalDigits vs. maxInclusive?

totaldigital和max包容性的实际行为是什么?

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

totaldigital是否总是用min包容性和max包容性的组合来表示?

How does totalDigits affect negative numbers?

全位数如何影响负数?

2 个解决方案

#1


6  

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

totaldigital是否总是用min包容性和max包容性的组合来表示?

In this case, yes. As you're dealing with an integer, the value must be a whole number, so you have a finite set of values between minInclusive and maxInclusive. If you had decimal values, totalDigits would tell you how many numbers in total that value could have.

在这种情况下,是的。当处理一个整数时,值必须是一个整数,所以在min包容性和max包容性之间有一组有限的值。如果你有十进制的值,totaldigit会告诉你该值总共有多少个数字。

How does totalDigits affect negative numbers?

全位数如何影响负数?

It is the total number of digits allowed in the number, and is not affected by decimal points, minus signs, etc. From 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.

facet的值属性指定的数字将限制十进制点两边的数字中允许的数字总数。

#2


2  

totalDigits is the total number of digits the number can have, including decimal numbers. So a totalDigits of 4 would allow 4.345 or 65.43 or 932.1 or a 4 digit whole integer as in the example above. Same for negative. Any of those previous examples can all be made negative and still validate as a totalDigits of 4.

totalnumbers是该数字包括小数在内的所有位数。所以4的总位数可以是4。345或65。43或932.1或4位整整数,如上面的例子。对负面的。前面的任何一个例子都可以变成负数,并且仍然以4的总位数进行验证。

max and min inclusive/exclusive limit the range of the numbers. The maxinclusive might seem be a little redundant in your example, but the mininclusive makes certain the number is greater than 0.

最大值和最小值(包括/排除)限制数字的范围。max包容性在您的示例中可能看起来有点多余,但min包容性确保数字大于0。

#1


6  

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

totaldigital是否总是用min包容性和max包容性的组合来表示?

In this case, yes. As you're dealing with an integer, the value must be a whole number, so you have a finite set of values between minInclusive and maxInclusive. If you had decimal values, totalDigits would tell you how many numbers in total that value could have.

在这种情况下,是的。当处理一个整数时,值必须是一个整数,所以在min包容性和max包容性之间有一组有限的值。如果你有十进制的值,totaldigit会告诉你该值总共有多少个数字。

How does totalDigits affect negative numbers?

全位数如何影响负数?

It is the total number of digits allowed in the number, and is not affected by decimal points, minus signs, etc. From 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.

facet的值属性指定的数字将限制十进制点两边的数字中允许的数字总数。

#2


2  

totalDigits is the total number of digits the number can have, including decimal numbers. So a totalDigits of 4 would allow 4.345 or 65.43 or 932.1 or a 4 digit whole integer as in the example above. Same for negative. Any of those previous examples can all be made negative and still validate as a totalDigits of 4.

totalnumbers是该数字包括小数在内的所有位数。所以4的总位数可以是4。345或65。43或932.1或4位整整数,如上面的例子。对负面的。前面的任何一个例子都可以变成负数,并且仍然以4的总位数进行验证。

max and min inclusive/exclusive limit the range of the numbers. The maxinclusive might seem be a little redundant in your example, but the mininclusive makes certain the number is greater than 0.

最大值和最小值(包括/排除)限制数字的范围。max包容性在您的示例中可能看起来有点多余,但min包容性确保数字大于0。