例外:在同一实体内开始和结束(不工作)

时间:2017-08-10 19:06:31

标签: xml xsd

我试图为冰淇淋创建简单的xml格式作为根元素,风味和大小作为子元素。但是有这个错误: - >

  

(XML文档结构必须在同一实体内开始和结束。   假)

即使我添加了相同的结束对标签,也会发生

。任何帮助表示赞赏。

我的xml file

<?xml version="1.0" encoding="UTF-8"?>
    <icecream xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="icecream.xsd">
        <flavour>Vanilla</flavour>
        <size>M</size>
    </icecream>

xsd file icecream.xsd

<?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="icecream">
    <xs:complexType>
            <xs:element name="flavour">
              <xs:complexType>
                <xs:restriction base="xs:string">
                  <xs:enumeration value="Vanilla"/>
                  <xs:enumeration value="StrawBerry"/>
                  <xs:enumeration value="Blackcurrent"/>
                    <xs:enumeration value="Butter Scotch"/>
                </xs:restriction>
              </xs:complexType>
            </xs:element> 
            <xs:element name="size">
              <xs:complexType>
                <xs:restriction base="xs:string">
                  <xs:enumeration value="S"/>
                  <xs:enumeration value="M"/>
                  <xs:enumeration value="L"/>
                </xs:restriction>
              </xs:complexType>
            </xs:element>
    </xs:complexType>
</xs:element>

0 个答案:

没有答案