我想将元素中允许的位数限制为 6:
<AccountNumber>123456</AccountNumber>
<AccountNumber>999999</AccountNumber>
<AccountNumber>000000</AccountNumber>
字段格式规范是 6 位、零填充的数字。
我读到我可能想使用限制totalDigits
,基于:
totalDigits
指定允许的确切位数。必须大于零
所以我有简单的类型:
<xs:simpleType name="AccountNumber">
<xs:restriction base="xs:int">
<xs:totalDigits value="6"/>
</xs:restriction>
</xs:simpleType>
虽然它会捕获无效数字,例如:
<AccountNumber>1234567</AccountNumber>
<AccountNumber>0000000</AccountNumber>
<AccountNumber></AccountNumber>
它不会捕获无效数字:
<AccountNumber>12345</AccountNumber>
<AccountNumber>01234</AccountNumber>
<AccountNumber>00123</AccountNumber>
<AccountNumber>00012</AccountNumber>
<AccountNumber>00001</AccountNumber>
<AccountNumber>00000</AccountNumber>
<AccountNumber>0000</AccountNumber>
<AccountNumber>000</AccountNumber>
<AccountNumber>00</AccountNumber>
<AccountNumber>0</AccountNumber>
指定允许的确切位数的建议限制是什么?