InputStream inputStream = input.openInputStream();
try {
InputSource inputSource = new InputSource(inputStream);
SaxEventAdapter saxEventAdapter = new SaxEventAdapter(input, eventHandler);
try {
XMLReader xmlReader = new SAXParser();
xmlReader.setContentHandler(saxEventAdapter);
xmlReader.setDTDHandler(saxEventAdapter);
xmlReader.setEntityResolver(saxEventAdapter);
xmlReader.setErrorHandler(saxEventAdapter);
// Enable full namespace handling.
xmlReader.setFeature("http://xml.org/sax/features/namespaces", true);
xmlReader.setFeature("http://xml.org/sax/features/namespace-prefixes", true);
xmlReader.parse(inputSource);
} catch (SAXException saxException) {
if (!saxEventAdapter.getExceptionMessages().contains(saxException.getMessage())) {
eventHandler.add(new SaxAlert(new SourcePosition(input),
Severity.ERROR, saxException));
}