1.把xml和xsd放在同一文件夹下
xsd:
<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
elementFormDefault="qualified" attributeFormDefault="qualified">
<xsd:element name="cmsversion">
<xsd:complexType>
<xsd:sequence>
<xsd:choice minOccurs="0" maxOccurs="unbounded">
<xsd:element name="keyprom">
<xsd:complexType>
<xsd:sequence>
<xsd:element ref="content" />
</xsd:sequence>
<xsd:attribute ref="name" use="required" />
</xsd:complexType>
</xsd:element>
<xsd:element name="group">
<xsd:complexType>
<xsd:sequence>
<xsd:element ref="content" />
</xsd:sequence>
<xsd:attribute ref="name" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="content">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="entry" maxOccurs="unbounded">
<xsd:complexType>
<xsd:complexContent>
<xsd:restriction base="xsd:anyType">
<xsd:attribute name="templetCode" type="xsd:string"
use="required">
<xsd:annotation>
<xsd:documentation>
名称
</xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="sort" type="xsd:boolean" use="required">
<xsd:annotation>
<xsd:documentation>
是否支持排序
</xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="repeat" type="xsd:boolean"
use="required">
<xsd:annotation>
<xsd:documentation>
是否支持重复
</xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="close" type="xsd:boolean"
use="required">
<xsd:annotation>
<xsd:documentation>
是否支持关闭
</xsd:documentation>
</xsd:annotation>
</xsd:attribute>
</xsd:restriction>
</xsd:complexContent>
</xsd:complexType>
</xsd:element>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:attribute name="name" type="xsd:string">
<xsd:annotation>
<xsd:documentation>
key的名称
</xsd:documentation>
</xsd:annotation>
</xsd:attribute>
</xsd:schema>
xml:
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<cmsversion xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="cms_version.xsd">
<!-- demo start -->
<group name="1">
<content>
<entry templetCode="1" sort="true" repeat="true" close="true" />
<entry templetCode="11" sort="false" repeat="true" close="true" />
</content>
</group>
<group name="2">
<content>
<entry templetCode="2" sort="true" repeat="false" close="true" />
</content>
</group>
<keyprom name="3">
<content>
<entry templetCode="3" sort="true" repeat="true" close="false" />
</content>
</keyprom>
<!-- demo end -->
</cmsversion>