Tony Hopkinson has given you the answer, but hasn't marked it as an answer. You don't have a book element in the xsd.
Validator shows me some error
-
30-06-2022 - |
Question
I made an XML file and XML Schema for validation. I tried it but it gives me some error.
XML file is well-formed, XML Schema is well-formed, too. But when I try Validate XML with XSD it gives me some errors. Pic: LINK
When I change line 2 in XSD to:
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.w3schools.com">
It gives me another error Pic:LINK
Can you help me where I am making the mistake please?
Update from 2013-10-14 10:57 (copied from answer):
Sorry I am little bit overworked, I didn't realize that I have missing book tag. However, it still gives me an error. What I am still doing wrong? I have attached my XML and XML schema.
<?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="http://www.w3schools.com">
<xs:element name="library">
<xs:complexType>
<xs:sequence>
<xs:element name="book"/>
<xs:element name="book_id" type="xs:integer"/>
<xs:element name="title" type="xs:string"/>
<xs:element name="author" type="xs:string"/>
<xs:element name="count" type="xs:integer"/>
<xs:element name="genre" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
<?xml version="1.0"?>
<library>
<book>
<book_id>5</book_id>
<title>Sokak</title>
<author>Tony</author>
<count>6</count>
<genre>epic</genre>
</book>
<book>
<book_id>13</book_id>
<title>Kucharka</title>
<author>Fiona</author>
<count>8</count>
<genre>Hobby</genre>
</book>
</library>
Solution
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow