<!--引用多个名称空间-->
<?xmlversion="1.0"encoding="UTF-8"?>
<!--引用多个命名空间-->
<f:familyxmlns:f="http://www.example.org/family"
xmlns:p="http://www.example.org/person"
xmlns:c="http://www.example.org/children"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.example.org/familyfamily.xsdhttp://www.example.org/personperson.xsdhttp://www.example.org/childrenchildren.xsd">
<!--多个命名空间的schemaLocation的地址可以依次写-->
<p:person>
<p:firstname></p:firstname>
<p:lastname></p:lastname>
<c:children>
<c:childname></c:childname>
</c:children>
</p:person>
</f:family>
<!--约束family文件-->
<?xmlversion="1.0"encoding="UTF-8"?>
<xs:schemaxmlns:xs="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://www.example.org/family"
xmlns:tns="http://www.example.org/family"
elementFormDefault="qualified">
<xs:elementname="family">
<xs:complexType>
<xs:sequence>
<xs:anyminOccurs="0"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
<!--children约束-->
<?xmlversion="1.0"encoding="UTF-8"?>
<xs:schemaxmlns:xs="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://www.example.org/children"
xmlns:tns="http://www.example.org/children"
elementFormDefault="qualified">
<!--定义children元素-->
<xs:elementname="children">
<!--复合类型-->
<xs:complexType>
<!--有序-->
<xs:sequence>
<!--childname可以出现无数次-->
<xs:elementname="childname"type="xs:string"
maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
<!--person约束-->
<?xmlversion="1.0"encoding="UTF-8"?>
<xs:schemaxmlns:xs="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://www.example.org/person"
xmlns:tns="http://www.example.org/person"
elementFormDefault="qualified">
<!--定义一个person元素-->
<xs:elementname="person">
<!--复合类型-->
<xs:complexType>
<!--有序-->
<xs:sequence>
<!--元素firstname-->
<xs:elementname="firstname"type="xs:string"/>
<!--元素lasttname-->
<xs:elementname="lastname"type="xs:string"/>
<!--留着扩展-->
<xs:anyminOccurs="0"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>