XSD 雜項 資料型別
其他雜項資料型別包括 boolean、base64Binary、hexBinary、float、double、anyURI、QName 和 NOTATION。
Boolean 資料型別
boolean 資料型別用於指定 true 或 false 值。
以下是 schema 中 boolean 宣告的示例
<xs:attribute name="disabled" type="xs:boolean"/>
您文件中的一個元素可能如下所示
<price disabled="true">999</price>
注意: boolean 的合法值是 true、false、1(表示 true)和 0(表示 false)。
Binary 資料型別
Binary 資料型別用於表示二進位制格式的資料。
我們有兩種 binary 資料型別
- base64Binary(Base64 編碼的二進位制資料)
- hexBinary(十六進位制編碼的二進位制資料)
以下是 schema 中 hexBinary 宣告的示例
<xs:element name="blobsrc" type="xs:hexBinary"/>
AnyURI 資料型別
anyURI 資料型別用於指定 URI。
以下是 schema 中 anyURI 宣告的示例
<xs:attribute name="src" type="xs:anyURI"/>
您文件中的一個元素可能如下所示
<pic src="https://w3schools.tw/images/smiley.gif" />
注意: 如果 URI 中包含空格,請將其替換為 %20。
Miscellaneous Data Types
名稱 | 描述 |
---|---|
anyURI | |
base64Binary | |
boolean | |
double | |
float | |
hexBinary | |
NOTATION | |
QName |
對雜項資料型別的約束
可用於其他資料型別的約束
- enumeration(布林資料型別不能使用此約束)
- length(布林資料型別不能使用此約束)
- maxLength(布林資料型別不能使用此約束)
- minLength(布林資料型別不能使用此約束)
- pattern
- whiteSpace