您的位置:首页 > 其它

Schema约束快速入门

2014-01-09 21:04 239 查看
Xml Schema 文件自身就是一个XML文件,但是它的扩展名通常为.xsd

一个XML Schema文档通常称之为模式文档(约束文档),遵循这个文档书写的XML文档为实例文档;

 complexType 复杂类型   sequence  要有顺序    unbounded  数量无上线

book.xsd

<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://www.itcast.cn"
elementFormDefault="qualified">
<xs:element name="书架">
<xs:complexType>
<xs:sequence maxOccurs='unbounded'>
<xs:element name="书">
<xs:complexType>
<xs:sequence>
<xs:element name="书名" type='xs:string'></xs:element>
<xs:element name="作者" type='xs:string'></xs:element>
<xs:element name="售价" type='xs:string'></xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>

</xs:schema> book.xml
<?xml version="1.0" encoding="UTF-8"?>
<itcast:书架  xmlns:itcast="http://www.itcast.cn"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.itcast.cn book.xsd">
<itcast:书>
<itcast:书名>javaScript网页开发</itcast:书名>
<itcast:作者>张孝祥</itcast:作者>
<itcast:售价>78.00元</itcast:售价>
</itcast:书>
</itcast:书架>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  Schema xml