This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
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, 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.
Joined: Aug 06, 2002
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