Click to See Complete Forum and Search --> : How to Validate XML againist XSD schema


naveenKurella
November 17th, 2003, 02:08 AM
I have XML file which is referring to .xsd file. whenever the .xml file is viewed in internet explorer, as it should check for the validation of .xsd file.

I removed .xsd file from the location which the .xml file is referring and then tried to open .xml file in Internet Explorer. No error message is given and opened nicely. as it supposed to give .xsd file is not found.

Can u give me solution for the above problem, how to validate .xml file against .xsd file, while opening the xml file. The fallowing are the XML file and XSD file which I used.

XSD file
=======

<?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://www.w3schools.com"
xmlns="http://www.w3schools.com"
elementFormDefault="qualified"><xs:element name="note">
<xs:complexType>
<xs:sequence>
<xs:element name="to" type="xs:string"/>
<xs:element name="from" type="xs:string"/>
<xs:element name="heading" type="xs:string"/>
<xs:element name="body" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:element></xs:schema>


XML file
=======
<?xml version="1.0"?>
<note xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="c:\note.xsd">
<to>Tove</to>
<from>Jani</from>
<heading>Reminder</heading>
<body>Don't forget me this weekend!</body>
</note>

amitreddy
November 20th, 2003, 02:28 AM
Hi Naveen,

I faced a similar problem, as far as I could figure out, IE does not validate an XML file even if it specfies a XSD, u have to write a code in a programming language to validate the XML file. IE simply parses it, and checks if all tags are closed properly. U can find more details for this at MSDN for MSXML, Xerces for C++.

Regards
Amit Reddy

naveenKurella
November 20th, 2003, 02:35 AM
Hi Amit,
Thanks for your reply.
I have searched in Microsoft.com also. They have given that MSXML 4.0 SP1 parser does not validate XML files against XSD.

regards,
Naveen