hi, i'm confused about validation of xml doc against its schema. suppose i've the followings: XML file ("note.xml"): ---------------------- <?xml version="1.0"?> <note xmlns="http://www.w3schools.com" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.w3schools.com/schema/note.xsd"> <to>Angel</to> <from>Helpless</from> <phone>238768</phone> <heading>Reminder</heading> <body>Don't forget me this weekend!</body> </note> And the schema ("note.xsd"): ----------------------------- <?xml version="1.0" encoding="ISO-8859-1"?> <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> if you look at the "note.xml" file where i've put an element "phone" which is not defined in schema "note.xsd". so when i validate from IE5 by right clicking on it and selecting Validate XML, no erorr is reported. i don't understand why. or is it because my validation process is wrong? my understanding is that a xml doc must not contain an element that's not defined in schema. please clarify me it. thanks. himal
Himal
Jayadev Pulaparty
Ranch Hand
Joined: Mar 25, 2002
Posts: 645
posted
0
I think for the xsi:schemaLocation you need to give the targetnamespace followed by the schema file name. I guess you missed giving the target namespace here. Try doing it that way.
Dan Drillich
Ranch Hand
Joined: Jul 09, 2001
Posts: 1123
posted
0
Himal, IE5 doesn't validate your XML file. I don't think it even looks at the schema file at all. In case of a DTD file, IE5 needs to retrieve entity values and default/constant values of attributes from the file. Therefore, IE5 checks the DTD syntax and reports DTD syntax errors. Cheers, Dan
William Butler Yeats: All life is a preparation for something that probably will never happen. Unless you make it happen.
Himal Chuli
Ranch Hand
Joined: Aug 06, 2002
Posts: 118
posted
0
hi dan, how could i validate a xml doc against its schema then? can you please let me know? would appreciate if anyone could tell me. thanks. himal
Balaji Loganathan
author and deputy
Bartender
Joined: Jul 13, 2001
Posts: 3150
posted
0
Download Topologi Schematron validator,or XMLSPY or use XSV online at W3C site,or download Sun MSV.....go thorough thier read me files,u will cometo know how to do it. Regards balaji