Hi all, Just a heads-up for anyone interested in validating XML against it's schemata. Sun's Multi-Schema XML Validator (MSV) software works great. Read about and download the software free at http://dcb.sun.com/practices/devnotebook/xml_msv.jsp One note, if you are using a DOM object, the example provided by SUN does not "appear" to be correct as the .verify() method does not accept a DOM argument... // check the validity of this DOM. if( schema.newVerifier().verify(dom) ) { // document is valid } else { // document is NOT valid }
My code uses an InputSource object instead... // Establish a StringReader object to the xmlData StringReader sr = new StringReader(xmlData); // Store the xmlData to an InputSource object InputSource input = new InputSource(sr); // When the xmlData is valid if (schema.newVerifier().verify(input)) { // Establish a new StringReader object StringReader sr2 = new StringReader(xmlData); // Store the xmlData to a new InputSource object InputSource input2 = new InputSource(sr2); // Establish a new DOMParser object DOMParser parser = new DOMParser(); // When the DOMParser is not null if (parser != null) { // Parse the xmlData parser.parse(input2); // Create the Document object for the xmlData dom = parser.getDocument(); } } else { // document is NOT valid } Hope this helps someone! Best Regards!!! Mike Cronin Data On Call
kiran manohar
Ranch Hand
Joined: Sep 28, 2003
Posts: 49
posted
0
hi mike The Sun's Multi-Schema XML Validator (MSV) software which u have listed in ur thread doesnot goto the specified site. could u help me get the software,bcoz i have a requirement which needs me to parse any xml string and store its data into a java object and vice versa Thanks Kiranmanohar
Balaji Loganathan
author and deputy
Bartender
Joined: Jul 13, 2001
Posts: 3150
posted
0
Originally posted by kiran manohar: hi mike The Sun's Multi-Schema XML Validator (MSV) software which u have listed in ur thread doesnot goto the specified site. could u help me get the software,bcoz i have a requirement which needs me to parse any xml string and store its data into a java object and vice versa Thanks Kiranmanohar