I'm trying to develop an XSD grammar according to a given XML file. The given XML file itemList.xml is shown as below.
<?xml version="1.0" encoding = "utf-8"?>
<itemList
xmlns="http://www.w3schools.com"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.w3schools.com itemList.xsd" >
<item>spoon</item>
<item>knife</item>
<item>fork</item>
<item>cup</item>
</itemList>
The itemList.xsd file that I developed is shown as below.
<schema
xmlns="http://www.w3.org/2001/XMLSchema"
xmlns:co="http://www.w3schools.com"
targetNamespace="http://www.w3schools.com"
elementFormDefault="qualified">
<simpleType name="itemType">
<restriction base="string"/>
</simpleType>
<complexType name="itemListType">
<sequence>
<element name="item" type="co:itemType"/>
</sequence>
</complexType>
<element name="itemList" type="co:itemListType"/>
</schema>
When I validate the XML against the XSD using this XML validator, I get the error
Cvc-complex-type.2.4.d: Invalid Content Was Found Starting With Element 'item'. No Child Element Is Expected At This Point.. Line '6', Column '12'.
It seems that I should rewrite my complexType
in itemList.xsd, but I'm not sure what to do. Many thanks to whoever could help.