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 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约束快速入门
- Schema约束快速入门
- MySQL快速入门05----列属性 & 列约束 & 主键
- javawebday07补充(jaxp增删查替换节点 2个工厂Document Transformer schema约束入门)
- 第8天(就业班) xml约束、Schema约束、Web开发入门、tomcat服务器、手动开发动态资源
- XOOPS模块开发快速入门中文翻译(五)
- Linux下Makefile快速编写入门
- Web基础知识二之Html快速入门
- XOOPS模块开发快速入门中文翻译(七)
- 正则表达式快速入门
- 微信公众号之免登陆快速入门
- 英特尔® Integrated Native Development Experience (Intel® INDE)快速入门
- kafka快速入门
- vue2+vuex+vue-router 快速入门(三) vue 实例介绍
- Yii快速入门教程
- XSLT Designer快速入门指南
- .NET之ASPWebApplication快速入门(4)
- ADO快速入门
- Java 5 泛型快速入门
- Castle Active Record for .NET2.0快速入门示例