XSD 數字 資料型別
Decimal 資料型別用於數值。
Decimal 資料型別
Decimal 資料型別用於指定數值。
以下是 Schema 中 decimal 宣告的示例
<xs:element name="price" type="xs:decimal"/>
您文件中的一個元素可能如下所示
<price>999.50</price>
或者可能看起來像這樣
<price>+999.5450</price>
或者可能看起來像這樣
<price>-999.5230</price>
或者可能看起來像這樣
<price>0</price>
或者可能看起來像這樣
<price>14</price>
Integer 資料型別
Integer 資料型別用於指定沒有小數部分的數值。
以下是 Schema 中 integer 宣告的示例
<xs:element name="price" type="xs:integer"/>
您文件中的一個元素可能如下所示
<price>999</price>
或者可能看起來像這樣
<price>+999</price>
或者可能看起來像這樣
<price>-999</price>
或者可能看起來像這樣
<price>0</price>
數值資料型別
請注意,以下所有資料型別都派生自 Decimal 資料型別(decimal 本身除外)!
名稱 | 描述 |
---|---|
byte | 帶符號的 8 位整數 |
decimal | Decimal 值 |
int | 帶符號的 32 位整數 |
整數 | 整數值 |
long | 帶符號的 64 位整數 |
negativeInteger | 僅包含負值的整數(..,-2,-1) |
nonNegativeInteger | 僅包含非負值的整數(0,1,2,..) |
nonPositiveInteger | 僅包含非正值的整數(..,-2,-1,0) |
positiveInteger | 僅包含正值的整數(1,2,..) |
short | 帶符號的 16 位整數 |
unsignedLong | 無符號 64 位整數 |
unsignedInt | 無符號 32 位整數 |
unsignedShort | 無符號 16 位整數 |
unsignedByte | 無符號 8 位整數 |
數字資料型別的限制
可與數字資料型別一起使用的限制
- enumeration(列舉)
- fractionDigits(小數位數)
- maxExclusive(最大值不包含)
- maxInclusive(最大值包含)
- minExclusive(最小值不包含)
- minInclusive(最小值包含)
- pattern
- totalDigits(總位數)
- whiteSpace