XSD - 其他資料型別



XSD 還有一些其他重要的資料型別,例如布林型、二進位制型anyURI

<xs:boolean> 資料型別

<xs:boolean> 資料型別用於表示 true、false、1(表示 true)或 0(表示 false)值。

<xs:boolean> 示例

XSD 中的元素宣告:

<xs:element name = "pass" type = "xs:boolean"/>

XML 中的元素用法:

<pass>false</pass>

二進位制資料型別

二進位制資料型別用於表示二進位制值。兩種二進位制型別常用。

  • base64Binary - 表示 base64 編碼的二進位制資料

  • hexBinary - 表示十六進位制編碼的二進位制資料

<xs:hexbinary> 示例

XSD 中的元素宣告:

<xs:element name = "blob" type = "xs:hexBinary"/>

XML 中的元素用法:

<blob>9FEEF</blob>

<xs:anyURI> 資料型別

<xs:anyURI> 資料型別用於表示 URI。

<xs:anyURI> 示例

XSD 中的元素宣告:

<xs:attribute name = "resource" type = "xs:anyURI"/>

XML 中的元素用法:

<image resource = "https://tutorialspoint.tw/images/smiley.jpg" />

數值資料型別

以下是常用數值資料型別的列表。

序號 名稱及說明
1.

byte

帶符號的 8 位整數

2.

decimal

十進位制值

3.

int

帶符號的 32 位整數

4.

integer

整數

5.

long

帶符號的 64 位整數

6.

negativeInteger

只有負值的整數 (..,-2,-1)

7.

nonNegativeInteger

只有非負值的整數 (0,1,2,..)

8.

nonPositiveInteger

只有非正值的整數 (..,-2,-1,0)

9.

positiveInteger

只有正值的整數 (1,2,..)

10.

short

帶符號的 16 位整數

11.

unsignedLong

無符號的 64 位整數

12.

unsignedInt

無符號的 32 位整數

13.

unsignedShort

無符號的 16 位整數

14.

unsignedByte

無符號的 8 位整數

限制

除了布林型別外,以下型別的限制可用於其他資料型別:

  • 列舉
  • 長度
  • 最大長度
  • 最小長度
  • 模式
  • 空白字元
廣告
© . All rights reserved.