Reputation: 2051
I have a blog.xml and a Blog.xsd to validate the XML file. I am using http://www.xmlvalidation.com/?L=0 to validate both files but I'm getting an error.
Can you kindly tell me whats wrong?
Error:
blog.xml:
http://pastebin.com/He3xCxxC (sorry had to post it to pastebin (Due to SO's word limit)
Blog.xsd:
<xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="blog">
<xs:complexType>
<xs:sequence>
<xs:element name="post" maxOccurs="unbounded" minOccurs="0">
<xs:complexType>
<xs:sequence>
<xs:element type="xs:string" name="ptitle"/>
<xs:element type="xs:string" name="psubtitle"/>
<xs:element type="xs:anyURI" name="image"/>
<xs:element type="xs:string" name="author"/>
<xs:element type="xs:string" name="date"/>
<xs:element type="xs:string" name="par"/>
<xs:element type="xs:anyURI" name="source"/>
<xs:element type="xs:string" name="comments"/>
</xs:sequence>
<xs:attribute type="xs:byte" name="id" use="optional"/>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
Upvotes: 0
Views: 4252
Reputation: 13022
You have not set the targetNamespace
(ie "http://www.w3schools.com") of the schema.
<xs:schema attributeFormDefault="unqualified" targetNamespace="http://www.w3schools.com" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">
And schemalocation
must specify the namespace and the schema. This is why you must have an even number of elements in schemaLocation
.
<a:blog xmlns:a="http://www.w3schools.com" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.w3schools.com ./Blog.xsd">
Upvotes: 1