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'
//constants
static
String JAXP_SCHEMA_LANGUAGE =
"http://java.sun.com/xml/jaxp/properties/schemaLanguage";
static String W3C_XML_SCHEMA =
"http://www.w3.org/2001/XMLSchema";
static final String JAXP_SCHEMA_SOURCE =
"http://java.sun.com/xml/jaxp/properties/schemaSource";
try
{
SAXParserFactory spf = SAXParserFactory.newInstance();
spf.setNamespaceAware(true);
spf.setValidating(true);
SAXParser saxParser = spf.newSAXParser();
try
{
saxParser.setProperty(JAXP_SCHEMA_LANGUAGE, W3C_XML_SCHEMA);
}
catch (SAXNotRecognizedException x)
{
throw new RuntimeException( "Parser doesn't support XML Schema. "+x.getMessage());
}
saxParser.setProperty(JAXP_SCHEMA_SOURCE, new File("c:\\projects\\xml Mssaging\\bin\\XMLSchema.xsd"));
// Validate
XMLReader xmlReader = saxParser.getXMLReader();
errorChecker = new ErrorChecker( verboseErrors );
xmlReader.setErrorHandler( errorChecker );
// Validate
xmlReader.parse(new InputSource(new FileReader(inputFile)));
// 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