我正在使用XML进行英语考试,在尝试使用XSD验证XML时,我仍然遇到同样令人讨厌的错误。我正在使用https://www.xmlvalidation.com/
错误是:
s4s-elt-must-match.1: The content of 'Question' must match (annotation?, (simpleType | complexType)?, (unique | key | keyref)*)). A problem was found starting at: attribute.
这是(缩短的)XML内容:
<?xml version="1.0" encoding="UTF-8"?>
<Questions xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="questions.xsd">
<Question id="t1">
<Title>Call me after eight o'clock, we ... dinner by then. (finish)</Title>
<Type>Textfield</Type>
<Answer>will have finished</Answer>
</Question>
<Question id="r1">
<Title>There was so much traffic, I was lucky to get ... the road without being kocked over.</Title>
<Type>Radio</Type>
<Answer correct="true">Across</Answer>
<Answer>Over</Answer>
<Answer>Through</Answer>
<Answer>Along</Answer>
</Question>
<Question id="d1">
<Title>I'm sorry, but he's already ....</Title>
<Type>DropDown</Type>
<Answer>Choose...</Answer>
<Answer>made</Answer>
<Answer>left</Answer>
<Answer correct="true">gone</Answer>
<Answer>had</Answer>
</Question>
<Question id="c1">
<Title>Which word form of 'think' is not correct?</Title>
<Type>Checkbox</Type>
<Answer correct="true">taught</Answer>
<Answer correct="true">though</Answer>
<Answer>thought</Answer>
<Answer>thinking</Answer>
</Question>
<Question id="cc1">
<Title>Which word form of 'danger' is not correct?</Title>
<Type>Cascade</Type>
<Answer>dangerous</Answer>
<Answer>dangerless</Answer>
<Answer>endanger</Answer>
<Answer correct="true">dangerfully</Answer>
</Question>
<Questions>
这是XSD内容:
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="Questions">
<xs:complexType>
<xs:sequence>
<xs:element name="Question" maxOccurs="25">
<xs:attribute name="id" />
<xs:complexType>
<xs:sequence>
<xs:element name="Title">
<xs:simpleType>
</xs:simpleType>
</xs:element>
<xs:element name="Type">
<xs:simpleType>
<xs:enumeration value="Textfield" />
<xs:enumeration value="Radio" />
<xs:enumeration value="DropDown" />
<xs:enumeration value="Checkbox" />
<xs:enumeration value="Cascade" />
</xs:simpleType>
</xs:element>
<xs:element name="Answer">
<xs:complexType>
<simpleContent>
<xs:attribute name="correct">
<xs:simpleType>
</xs:simpleType>
</xs:attribute>
</simpleContent>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
我对此很新,所以任何帮助都会非常感激。