Java Reference
In-Depth Information
DocumentBuilder builder = null;
try {
builder = factory.newDocumentBuilder();
} catch (ParserConfigurationException pce) {
pce.printStackTrace();
}
return builder;
}
}
/**
* This class gets notified by the parser in the event of a
* problem.
*/
class ValidationHandler extends DefaultHandler {
private boolean valid = true;
private SAXException se;
/**
* The default implementation does nothing.
*/
@Override
public void error(SAXParseException se) throws SAXException {
this.se = se;
valid = false;
throw se;
}
/**
* The default implementation does nothing.
*/
@Override
public void fatalError(SAXParseException se)
throws SAXException {
this.se = se;
valid = false;
throw se;
}
public boolean isValid() {
return valid;
}
}
Under normal circumstances, the program should give the following output:
Search WWH ::




Custom Search