Guys I really need ur help here.. I am trying to validate a schema file using JAXP1.2.. Here is my code .. I have no clue why I get this error Schema_reference 4: Failed to read schema document 'null'
// If error happened if ( errorChecker.errorHappened ) { isValid = false; // Suggest "verboseerrors" att if not on if ( ! verboseErrors ) { System.out.println( "Error. Set SchemaValidate's 'verbose errors' attribute to true for a more detailed description on warnings."); } } } catch (IOException e) { isValid = false; System.err.println("Error: IO Exception."); e.printStackTrace(); } catch (SAXException e) { isValid = false; System.err.println("Error: SAXException."); e.printStackTrace(); } catch (ParserConfigurationException e) { isValid = false; System.err.println("Error: ParserConfigurationException."); e.printStackTrace(); }
I would really appreciate any help...This thing has been bugging me for a few days now.. Thanks, Roopa
Anonymous
Ranch Hand
Joined: Nov 22, 2008
Posts: 18944
posted
0
Hi Roopa, I tried your code wich works perfectly for me. The thing that might not be working is the location of the xsd file (this is actually the error reported by your code: failed to read schema document). All your have to do is check the location of the file. The path "c:\\projects\\xml Mssaging\\bin\\XMLSchema.xsd" might actually be wrong (don't you miss a e in Mssaging for instance?). Cheers
Anonymous
Ranch Hand
Joined: Nov 22, 2008
Posts: 18944
posted
0
For reference, I used the following files for testing: - roopa.xml - roopa.xsd - Roopa.java Contents of roopa.xml: