1

I'm working on an English exam with XML and I keep getting the same annoying error when trying to validate my XML using XSD. I'm using https://www.xmlvalidation.com/

The error is:

s4s-elt-must-match.1: The content of 'Question' must match (annotation?, (simpleType | complexType)?, (unique | key | keyref)*)). A problem was found starting at: attribute.

This is the (shortened) XML content:

<?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>

And this is the XSD content:

<?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>

I'm quite new at this, so any help would be very appreciated.

Ivan Penev
  • 59
  • 5

0 Answers0