I’m currently playing around with some basic XS Schema stuff, but am getting an irritating error when attempting to validate my schema. I’m using XMLValidation.com and the error I’m getting is:
s4s-elt-must-match.1: The content of 'lecturers' must match (annotation?, (simpleType | complexType)?, (unique | key | keyref)*)). A problem was found starting at: element.
Then, my XSD is as follows:
<?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="lecturers">
<xs:element name="lecturer">
<xs:complexType>
<xs:sequence>
<xs:element name="name" type="xs:string" />
<xs:attribute name="title" type="xs:string" />
<xs:attribute name="first" type="xs:string" />
<xs:attribute name="last" type="xs:string" />
</xs:sequence>
</xs:complexType>
<xs:element name="teaching">
<xs:complexType>
<xs:sequence>
<xs:element name="course" type="xs:string" />
<xs:attribute name="code" type="xs:string" />
<xs:element name="course" type="xs:string" />
<xs:attribute name="code" type="xs:string" />
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="research" type="xs:string"/>
</xs:element>
</xs:element>
</xs:schema>
The corresponding XML file reads like:
<?xml version="1.0"?>
<lecturers xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="lecturers.xsd">
<lecturer>
<name title="Professor" first="Peter" last="Quirk" />
<teaching>
<course code="CO3070">XML and the Web</course>
<course code="CO3300">Web Server Architectures</course>
</teaching>
<research>The application of Web protocols to Biology</research>
</lecturer>
</lecturers>
Anyone have any ideas why my code isn’t validating and what I can do to sort it out. Thanks in advance
I got the following to work…