开发者

xml maxLength for decimal type

开发者 https://www.devze.com 2023-03-09 04:09 出处:网络
I tried the following to set the maximum length for a decimal: <simpleType name=\'xxx\'> <restriction base=\'decimal\'>

I tried the following to set the maximum length for a decimal:

<simpleType name='xxx'>
    <restriction base='decimal'>
        <maxLength value开发者_运维技巧='7'/>
    </restriction>
</simpleType>

but this is not valid syntax. Can I use maxLength for decimal?


Can i use maxLength for decimal?

A correct answer would require checking the W3C Recommendation, but a check of my quick reference: maxLength only applies to string types.


I think you need to use totalDigits instead:

http://www.ibm.com/developerworks/xml/library/x-xdarch.html


You can use minInclusive and maxInclusive instead.

An example from W3Schools:

<xs:element name="age">
  <xs:simpleType>
    <xs:restriction base="xs:integer">
      <xs:minInclusive value="0"/>
      <xs:maxInclusive value="120"/>
    </xs:restriction>
  </xs:simpleType>
</xs:element>

There are also minExclusive, maxExclusive and totalDigits restrictions.

0

精彩评论

暂无评论...
验证码 换一张
取 消