Hi all,
I have a XML file which is to be validated against a XSD file. I am able to know the error but could not able to catch that error.
Following the error message:-
Warning: validation was turned on but an org.xml.sax.ErrorHandler was not set, which is probably not what is desired. Parser will use a default ErrorHandler to print the first 10 errors. Please call the setErrorHandler method to fix this.
Error: URI = "file:C:/TBWS-1.0/XMLProcessing/note.xml", Line = "4", : cvc-datatype-valid.1.2.1: 'xcf' is not a valid value for 'integer'.
Error: URI = "file:C:/TBWS-1.0/XMLProcessing/note.xml", Line = "4", : cvc-type.3.1.3: The value 'xcf' of element 'to' is not valid.
and here is my code:
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
factory.setValidating(true);
factory.setNamespaceAware(true);
//Set the XML Schema language against which this XML file is to validate
factory.setAttribute("http://java.sun.com/xml/jaxp/properties/schemaLanguage",
"http://www.w3.org/2001/XMLSchema");
factory.setAttribute("http://java.sun.com/xml/jaxp/properties/schemaSource", "note.xsd");
try
{
DocumentBuilder builder = factory.newDocumentBuilder();
document = builder.parse(new File("note.xml"));
}
catch (SAXException sxe)
{
sxe.printStackTrace();
}
catch (ParserConfigurationException pce)
{
pce.printStackTrace();
}
catch (IOException ioe)
{
ioe.printStackTrace();
}
Any help will be appriciable.