Validating via JUnit
public void testValidOutput() throws SAXException, IOEXception {
File f = new File("filename.xml");
InputSource in = new InputSource(new FileInputStream(f));
XMLReader parser = XMLReaderFactory.createXMLReader();
parser.setFeature("http://xml.org/sax/features/validation", true);
parser.setErrorHandler(new ErrorHandler() {
public void warning(SAXParseException exception) {
// skip
}
public void error(SAXParseException exception)
throws SAXException {
throw exception;
}
public void fatalError(SAXParseException exception)
throws SAXException {
throw exception;
}
});
parser.parse(in);
}