我正在试图弄清楚当我在http://corefiling.com/opensource/schemaValidate.html使用验证器时此错误的含义。这是我从这个验证器收到的错误。
s4s-elt-must-match.1: The content of 'orders' must match (annotation?, (simpleType |
complexType)?, (unique | key | keyref)*)).
A problem was found starting at: element.
这个错误给我带来了什么信息?
这是我的xsd文件
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="orders">
<xs:element name ="order" maxOccurs="unbounded">
<xs:complexType>
<xs:sequence>
<xs:element name="case" type="xs:caseColor" >
<xs:simpleType name="caseColor">
<xs:restriction base="string">
<xs:enumeration value="Lemonde" />
<xs:enumeration value="Strawberry" />
<xs:enumeration value="Lime" />
<xs:enumeration value="Blueberry" />
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="batteries" type="xs:numOfBat" default =
"1">
<xs:simpleType name="numOfBat">
<xs:restriction base="integer">
<xs:enumeration value="1" />
<xs:enumeration value="2" />
<xs:enumeration value="3" />
<xs:enumeration value="4" />
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="recharger" type="xs:volt">
<xs:simpleType name="volt">
<xs:restriction base="string">
<xs:enumeration value="110-120" />
<xs:enumeration value="220-240" />
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="arm">
<xs:element name ="reaches" minOccurs="2" maxOccurs="3"
type="xs:reach">
<xs:simpleType name="reach">
<xs:restriction base = "integer">
<xs:enumeration value = "50" />
<xs:enumeration value = "75" />
<xs:enumeration value = "100" />
</xs:restriction>
</xs:simpleType>
</xs:element>
</xs:element>
<xs:element name ="camera" type="numOfCam">
<xs:simpleType name="numOfCam">
<xs:restriction base="string">
<xs:enumeration value="1" />
<xs:enumeration value="2" />
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name = "speech" type="xs:language">
<xs:simpleType name = "language">
<xs:restriction base = "string">
<xs:enumeration value = "Spanish" />
<xs:enumeration value = "Chinese" />
<xs:enumeration value = "English" />
<xs:enumeration value = "German" />
<xs:enumeration value = "French" />
</xs:restriction>
</xs:simpleType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:element>
</xs:schema>
这是我的xml文件
<?xml version="1.0" encoding="UTF-8"?>
<orders>
<order>
<case> Strawberry </case>
<batteries> 2 </batteries>
<recharger> 110-120 V </recharger>
<arm> 2
<length> 50 </length>
<length> 100 </length>
</arm>
<camera> 2 </camera>
<speech> Spanish </speech>
</order>
<order>
<case> Lime </case>
<batteries> 4 </batteries>
<recharger> 220-240 V </recharger>
<arm> 3
<length> 75 </length>
<length> 75 </length>
<length> 100 </length>
</arm>
<camera> 1 </camera>
<speech> Chinese </speech>
</order>
<order>
<case> Blueberry </case>
<batteries> 1 </batteries>
<recharger> 110-120 V </recharger>
<arm> 2
<length> 75 </length>
<length> 100 </length>
</arm>
<camera> 2 </camera>
<speech> French </speech>
</order>
</orders>
答案 0 :(得分:1)
我修复了所有这些错误,请参考下面的改进代码:
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="orders">
<xs:complexType>
<xs:sequence>
<xs:element name ="order" maxOccurs="unbounded">
<xs:complexType>
<xs:sequence>
<xs:element name="case">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:enumeration value="Lemonde" />
<xs:enumeration value="Strawberry" />
<xs:enumeration value="Lime" />
<xs:enumeration value="Blueberry" />
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="batteries" default =
"1">
<xs:simpleType>
<xs:restriction base="xs:integer">
<xs:enumeration value="1" />
<xs:enumeration value="2" />
<xs:enumeration value="3" />
<xs:enumeration value="4" />
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="recharger">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:enumeration value="110-120" />
<xs:enumeration value="220-240" />
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="arm">
<xs:complexType>
<xs:sequence>
<xs:element name ="reaches" minOccurs="2" maxOccurs="3">
<xs:simpleType>
<xs:restriction base = "xs:integer">
<xs:enumeration value = "50" />
<xs:enumeration value = "75" />
<xs:enumeration value = "100" />
</xs:restriction>
</xs:simpleType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name ="camera">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:enumeration value="1" />
<xs:enumeration value="2" />
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name = "speech">
<xs:simpleType>
<xs:restriction base = "xs:string">
<xs:enumeration value = "Spanish" />
<xs:enumeration value = "Chinese" />
<xs:enumeration value = "English" />
<xs:enumeration value = "German" />
<xs:enumeration value = "French" />
</xs:restriction>
</xs:simpleType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>