XML(4)——schema文件相互引用
两个xsd必须在同一命名空间下targetNamespace。student.xsd
<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns:xsd="https://www.w3.org/2001/XMLSchema"
targetNamespace="https://www.example.org/classroom"
xmlns:tns="https://www.example.org/classroom"
elementFormDefault="qualified">
<xsd:element name="student" type="tns:studentType"/>
<xsd:complexType name="studentType">
<xsd:sequence>
<xsd:element name="name" type="xsd:string"/>
<xsd:element name="sex" type="tns:sexType"/>
</xsd:sequence>
</xsd:complexType>
<xsd:simpleType name="sexType">
<xsd:restriction base="xsd:string">
<xsd:enumeration value="男"/>
<xsd:enumeration value="女"/>
</xsd:restriction>
</xsd:simpleType>
</xsd:schema>
classroom.xsd
<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns:xsd="https://www.w3.org/2001/XMLSchema"
targetNamespace="https://www.example.org/classroom"
xmlns:tns="https://www.example.org/classroom"
elementFormDefault="qualified">
<!-- 两个文件必须在同一个命名空间下(targetNamespace) -->
<xsd:include schemaLocation="student.xsd"/>
<xsd:element name="classroom" type="tns:classroomType"/>
<xsd:complexType name="classroomType">
<xsd:sequence>
<xsd:element name="grade" type="tns:gradeType"/>
<xsd:element name="name" type="xsd:string"/>
<xsd:sequence minOccurs="1" maxOccurs="unbounded">
<xsd:element name="student" type="tns:studentType"/>
</xsd:sequence>
</xsd:sequence>
</xsd:complexType>
<xsd:simpleType name="gradeType">
<xsd:restriction base="xsd:int">
<xsd:minInclusive value="2000"/>
<xsd:maxInclusive value="3000"/>
</xsd:restriction>
</xsd:simpleType>
</xsd:schema>
最后更新:2017-04-03 20:19:27
上一篇:
JAVA线程中的生产者和消费者问题
下一篇:
修改android最小堆内存
空间|时间|对象 圈人 + 目标人群透视 - 暨PostgreSQL 10与Greenplum的对比和选择
列出所有请求表单提交数据的通用jsp脚本,调试可以使用
从零开始学习OpenCL开发(四)shader
EditTextPreference InputFilter过滤字符串及限制长度的实现
迁移到云端的企业数据需注意安全
Apache Common Math Stat
使用C#调用旋风快车和迅雷下载文件 也是C#调用Com的好例子!
windowsXP下搭建JAVA环境教程
Java线程池架构原理和源码解析(ThreadPoolExecutor)
《Hadoop与大数据挖掘》一2.1.3 Hadoop计算—MapReduce