if (grammar == null)
throw new RuntimeException(
"Unexpected failure parsing grammar URL '"
+ grammarUrl + "'");
RelmesVerifier verifier;
XMLReader reader;
CatalogResolver catalogResolver = new CatalogResolver();
for (int i = 0; i < sourceUrls.length; i++ ) {
verifier = new RelmesVerifier(
new REDocumentDeclaration(grammar),
new ReportErrorHandler());
reader = factory.newSAXParser().getXMLReader();
reader.setEntityResolver(catalogResolver);
reader.setContentHandler(verifier);
if (verbose)
System.out.print("Validating " + sourceUrls[i] + "... ");
try {
reader.parse(new InputSource(sourceUrls[i].openStream()));
} catch (SAXException e) {
if (verbose) System.out.println(); // See note below
cause = e.getCause();
System.err.println(
cause == null ? e.toString() : cause.toString());
}
if (verifier.isValid()) {
if (verbose) System.out.println("valid");
} else {
exitStatus++;
System.err.println(sourceUrls[i] + " INVALID!");
}