Schema
<!--hr.xsd-->
<?xml versionn="1.0" encoding= "UTF-8"?>
<schema xmlns="http://www.3c.org/2001/XMLSchema">
<element name="hr">
<!--complexType标签含义是复杂节点,包含子节点时必须使用这个标签-->
<complexType>
<!--sequence标签含义是序列,其子节点必须按顺序严格书写-->
<sequence>
<element name="employee" minOccurs="1" maxOccurs="9999">
<complexType>
<sequence>
<element name="name" type="string"/>
<element name="age">
<!--simpleType的含义是简单节点,不含有子节点-->
<simpleType>
<!--restriction的含义是约束,用于对标签的限定-->
<restriction base="integer">
<minInclusive value"18"/>
<maxInclusive value"60"/>
</restriction>
</simpleType>
</element>
<element name="salary" type="double"/>
<element name="department">
<sequence>
<element name="dname" type="string"/>
<element name="address" type="string"/>
</sequence>
</element>
</sequence>
<complexType>
</element>
</sequence>
<!--attribute标签的含义是属性,用于设置属性-->
<attribute name="no" type="string" use="required"/>
</complexType>
</element>
</schema>
XML
<?xml version="1.0" encoding="UTF-8"?>
<!--人力资源管理系统-->
<hr xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="hr.xsd">
<employee no="3309">
<name>张三</name>
<age>23</age>
<salary>7000</salary>
<department>
<dname>会计部</dname>
<address>XX大厦-B401</address>
</department>
</employee>
<employee no="3310">
<name>李四</name>
<age>27</age>
<salary>10000</salary>
<department>
<dname>研发部</dname>
<address>XX大厦-B402</address>
</department>
</employee>
</hr>