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