XML——Schema
body, table{font-family: 微软雅黑; font-size: 10pt}
table{border-collapse: collapse; border: solid gray; border-width: 2px 0 2px 0;}
th{border: 1px solid gray; padding: 4px; background-color: #DDD;}
td{border: 1px solid gray; padding: 4px;}
tr:nth-child(2n){background-color: #f8f8f8;}
|
<schema> 元素是每一个 XML Schema 的根元素;
xmlns:xs=“http://www.w3.org/2001/XMLSchema” //标准的名称空间, 表示schema 中用到的元素和数据类型来自命名空间 "http://www.w3.org/2001/XMLSchema"。同时它还规定了来自命名空间 "http://www.w3.org/2001/XMLSchema" 的元素和数据类型应该使用前缀 xs:
targetNamespace=“http://www.cskaoyan.com”显示被此 schema 定义的元素 (name, author, price ) 来自命名空间: "http://www.cskaoyan.com"。//这个可以随便改
elementFormDefault="qualified" 指出任何 XML 实例文档所使用的且在此 schema 中声明过的元素必须被命名空间限定。
|
| MySchema.xsd | NewFile.xml |
|
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema
xmlns:xs="http://www.w3.org/2001/XMLSchema" //这里都是这个
targetNamespace="http://www.example.org/MySchema" //定义自己的命名空间,“随便写”
elementFormDefault="qualified"> //声明实例要被命名空间限定
<xs:element name='书架'>
<xs:complexType>
<xs:sequence maxOccurs='unbounded' >
<xs:element name='书' >
<xs:complexType> // 元素定义复杂类型。复杂类型的元素是包含其他元素和/或属性的 XML 元素
<xs:sequence>
<xs:element name='书名' type='xs:string' />
<xs:element name='作者' type='xs:string' />
<xs:element name='售价' type='xs:string' />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
|
<?xml version="1.0" encoding="UTF-8"?>
<书架 xmlns="http://www.example.org/MySchema" //根据上面的xsd文档,写出这个
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" //一般都是这个
xsi:schemaLocation="http://www.example.org/MySchema MySchema.xsd"> //前面也要加上xsd定义的目标命名空间
<书>
<书名>java面试版本</书名>
<作者>XXX</作者>
<售价>30</售价>
</书>
</书架>
<?xml version="1.0" encoding="UTF-8"?>
<meihao:书架 xmlns:meihao="http://www.example.org/MySchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.example.org/MySchema MySchema.xsd">
<meihao:书>
<meihao:书名>java面试版本</meihao:书名>
<meihao:作者>XXX</meihao:作者>
<meihao:售价>30</meihao:售价>
</meihao:书>
</meihao:书架>
|
XML——Schema的更多相关文章
- XML Schema and XMLspy notes
Introduction An xml documents consists of elements, attributes and text. There are two structures in ...
- XSD(XML Schema Definition)用法实例介绍以及C#使用xsd文件验证XML格式
XML Schema 语言也称作 XML Schema 定义(XML Schema Definition,XSD),作用是定义 XML 文档的合法构建模块,类似 DTD,但更加强大. 作用有: ①定义 ...
- XML Schema命名空间解析
URI Web中汇集了各种资源.资源可以是具有标识的任何事物, 如文档. 文件. 菜单项. 计算机. 服务等, 甚至可以包括人. 组织和概念[BernersLee 1998].在Web体系结构中, ...
- 【转】XSD (xml Schema Definition)
来自:http://www.cnblogs.com/newsouls/archive/2011/10/28/2227765.html Xml Schema的用途 1. 定义一个Xml文档中都有什么元 ...
- C#与XML Schema的问题
http://bbs.csdn.net/topics/50493564 weileily: 用XmlSchema.Read方法读取了一个xsd文件,请问如何遍历检索器中的ComplexType与Sim ...
- XML Schema的基本语法(转)
XML Schema的基本语法(转) XSDL(XML Schema定义语言)由元素.属性.命名空间和XML文档种的其他节点构成的. 一.XSD中的元素 XSD文档至少要包含:schema根元素和XM ...
- Xml Schema:C#访问在complextype中插入新元素
最近用c#写Xml Schema代码,找了很久也找不到如何在已有的complextype中插入新的element,最后我充分发挥自己的聪明才智,哈哈,终于从...中找到了灵感. XmlSchemaSe ...
- [BTS] System.Xml.Schema.XmlSchemaException: The complexType has already been declared when generate IDoc schema.
I use wcf-sap adapter for generate the schema of IDoc that named "YHREMPMASTER". but throw ...
- onfiguration problem: Unable to locate Spring NamespaceHandler for XML schema namespace [http://www.springframework.org/schema/security]
org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: Una ...
- dubbo源码之一——xml schema扩展
dubbo源码版本:2.5.4 dubbo-parent |----dubbo-config |----dubbo-config-api |----com.alibaba.dubbo.config.* ...
随机推荐
- linux下如何查看当前机器提供了哪些服务
答:使用netstat工具 在命令行下输入netstat -atun即可列出当前机器提供的服务 netstat各选项解析: -a 列出所有服务 -t 列出tcp相关 -u 列出udp相关 -n 以数字 ...
- SQL Over
与over函数结合的几个函数 create table #tab(A varchar(), B varchar()) insert into #tab select 'A1', 'B1' union ...
- Linux环境下的定时任务(转载)
今天做了个数据库的备份脚本,顺便系统得学习一下Linux下定时执行脚本的设置.Linux下的定时执行主要是使用crontab文件中加入定制计划来执行,设置比Windows稍微复杂一些(因为没有图形界面 ...
- python 正则表达式匹配特定浮点数
def is_decimal(num): import re #以数字开头,小数点后保留1位数字或两位数字或者没有小数部分 dnumre = re.compile(r""" ...
- python 集合交集
#Intersection setx = set(["green", "blue"]) sety = set(["blue", " ...
- python 集合并集
#Union setx = set(["green", "blue"]) sety = set(["blue", "yellow& ...
- Ubuntu14.04 ,libboost_filesystem.so.1.54.0: cannot open shared object file: No such file or directory
macname@ubuntu:/opt$ roslaunch blarospack : error : cannot open shared object file: No such file or ...
- python中sys.stdout、sys.stdin
如果需要更好的控制输出,而print不能满足需求,sys.stdout,sys.stdin,sys.stderr就是你需要的. 1. sys.stdout与print: 在python中调用print ...
- QString 编码转换
参考网址:http://blog.csdn.net/lfw19891101/article/details/6641785 (网页保存于:百度云CodeSkill33 --> 全部文件 > ...
- vmware 安装ubuntu
点击自定义硬件 即将完毕 下面就是安装啦