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 16:49:21
上一篇:
Java中線程封閉之ThreadLocal
下一篇:
修改android最小堆內存
在Android中通過jni方式使用編譯好的FFmpeg庫-Android中使用FFmpeg媒體庫(二)
js數據類型有哪些
IBM 3390:世界最貴硬盤驅動器
???????????????Elasticsearch????????????2????????????2.2.3????????????????????????-??????-????????????-?????????
PHP連接數據庫學習手冊
如何更改 Linux I/O 調度器來調整性能
阿裏雲免費企業郵箱申請流程
Java中連接各種數據庫
創業公司如何做數據分析(四)ELK日誌係統
想做好外貿網站Google優化?你需要知道這些優化技巧