shema基础:
shema的使用:
shema的属性和语法:
相应的源码:
1.shema的格式:
<?xml version="1.0" encoding="UTF-8"?>
<schema xmlns="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://www.example.org/02"
xmlns:tns="http://www.example.org/02"
elementFormDefault="qualified">
<element name="books">
<complexType>
<sequence maxOccurs="unbounded">
<element name="book">
<complexType>
<sequence>
<element name="title" type="string"></element>
<element name="content" type="string"></element>
<choice>
<element name="author" type="string"></element>
<element name="authors">
<complexType>
<sequence maxOccurs="3">
<element name="author" type="string"></element>
</sequence>
</complexType>
</element>
</choice>
</sequence>
<attribute name="id" type="int" use="required"/>
</complexType>
</element>
</sequence>
</complexType>
</element>
</schema>
2.shema控制的xml文件
<?xml version="1.0" encoding="UTF-8"?>
<books xmlns="http://www.example.org/02"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.example.org/02">
<book id="1">
<title>think in java</title>
<content>hello java world</content>
<author>zizhu</author>
</book>
<book id="2">
<title>think in java (4 edition)</title>
<content>base java</content>
<authors>
<author>bruce</author>
<author>mike</author>
</authors>
</book>
</books>