schema实现对xml的约束

来源:互联网 发布:冥王星的早餐知乎 编辑:程序博客网 时间:2024/05/20 03:05

config.xsd:

<?xml version='1.0' encoding='UTF-8'?><xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"           targetNamespace="http://example.org"           elementFormDefault="qualified">    <xs:element name="config">        <xs:complexType>            <xs:sequence>                <xs:element name="item">                    <xs:complexType>                        <xs:attribute name="type" type="xs:string"/>                        <xs:attribute name="class" type="xs:string"/>                    </xs:complexType>                </xs:element>            </xs:sequence>        </xs:complexType>    </xs:element></xs:schema>

config.xml

<?xml version='1.0' encoding='UTF-8'?><config xmlns="http://example.org">    <item type="zhongtong" class="com.springmvc.kdHelper.DataList"/></config>

参考链接:

XML文档中如何引入Schema



原创粉丝点击