1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23 |
编写的schema约束<br><?xml version= "1.0"
encoding= "utf-8" ?> <xs:schema xmlns:xs= "http://www.w3.org/2001/XMLSchema" targetNamespace= "http://www.stella.cn" elementFormDefault= "qualified" > <xs:element name= "学生管理系统" > <xs:complexType> <xs:sequence maxOccurs= "unbounded" > <xs:element name= "学生" > <xs:complexType> <xs:sequence> <xs:element name= "编号"
type= "xs:decimal" /> <xs:element name= "姓名"
type= "xs:string" /> <xs:element name= "性别"
type= "xs:string" /> <xs:element name= "年龄"
type= "xs:integer" /> <xs:element name= "密码"
type= "xs:string" /> </xs:sequence> <span style= "color: rgb(255, 0, 0);" ><xs:attribute name= "id"
type= "xs:integer"
use= "required" /></span> </xs:complexType> </xs:element> </xs:sequence> </xs:complexType> </xs:element> </xs:schema> |
以下是用到这个约束的xml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 |
<?xml version= "1.0"
encoding= "UTF-8" ?> <s:学生管理系统 xmlns:s= "http://www.stella.cn" xmlns:xsi= "http://www.w3.org/2001/XMLSchema-instance" <s:学生 id= "1" > <s:编号> 89757 </s:编号> <s:姓名> jack </s:姓名> <s:性别> 女 </s:性别> <s:年龄> 18 </s:年龄> <s:密码> 789 </s:密码> </s:学生> </s:学生管理系统> |
原文:http://www.cnblogs.com/lxricecream/p/3641622.html