Hi all,
I am parsing an XML file passed in at the cmd line and using this method to return a boolean if depending if the validation was ok....I have successfully validated against the particular file that I am passing in against a valid XSD and it works fine. But when I do this here it gets caught as an error straight away.
Can anyone see any obvious mistakes with this code or have any suggestions?
public boolean validateXML() {
try {
boolean validate = true;
parser.setFeature("http://xml.org/sax/features/validation", validate);
//CustomerErrorHandler extends SAX ErrorHandler
CustomErrorHandler handler = new CustomErrorHandler();
//Install/Enable the parser to handle parsing errors
parser.setErrorHandler(handler);
parser.parse(args[0]);
System.out.println("YOU ARE IN THE XMLVALIDATOR CODE NOW!!!!");
validXML = true;
}
catch (Exception ex) {
System.out.println("An error has been caught, following validation");
validXML = false;
}
return validXML;
}