1. 程式人生 > >xml schema數據類型

xml schema數據類型

mine simple 字符串 maxlength value 定時 lap 大於等於 標識

1.簡單數據類型

(1)內置簡單數據類型

schema中定義了一些簡單數據類型,包括primitive原始數據類型和derived派生數據類型,這些類型都是schema中使用的

最基本的數據類型,我們可以用他們自定義簡單數據類型

表:primitive原始數據類型

數據類型 描述
string 字符串
Boolean 布爾值
decimal 十進制數字
float 32位浮點數
double 64位浮點數
timeDuration 標識持續時間
datetime 特定時間
time
date
anyURI 代表URI,用來定位文件
recurring Duration

派生數據類型

數據類型 描述
integer
long [-263,263-1]
nonNegativeInteger 大於等於零的整數
positiveInteger 大於零的整數
int [-231,231-1]
time s
date

(2)自定義簡單數據類型

<xs:simpleType name="phoneno">
  <xs:restriction base="xs:string">
    <xs:length value="3" />
    <xs:pattern value
="\d{4}-\d{3}" />   </xs:restriction> </xs:simpleType>

simpleType元素常用子元素

子元素 作用
enumeration 枚舉類型,供用戶選擇
fractionDigits 限定最大的小數位,用戶控制精度
length 自定數據的長度
maxExclusive 指定數據的最大值(小於)
maxInclusive 指定數據的最大值(小於等於)
maxLength 指定長度的最大值
minExclusive 指定最小值(大於)
minInclusive 指定最小值(小於等於)
minLength 指定最小長度
pattern 正則

e.g.

<xs:simpleType name="gender">
  <xs:restriction base="xs:string">
    <xs:enumeration value="男"/>
    <xs:enumeration vlaue="女"/>
  </xs:restriction>
</xs:simpleType>

2.復雜數據類型

<xs:complexType name="">

  <內容模板定義(包括子元素和屬性的聲明)

</xs:complexType>

e.g.

技術分享
1 <xs:complexType name="address">
2   <xs:sequence>
3     <xs:element name="street" type="xs:string" />
4     <xs:element name="city" type="xs:string" />
5     <xs:element name="state" type="xs:string" />
6     <xs:element name="zip" type="xs:decimal" />
7   </xs:sequence>
8 </xs:complexType>
復雜數據類型

xml schema數據類型