if (fIncludeLocations.contains((Object)location)) {
return;
}
fIncludeLocations.addElement((Object)location);
DOMParser parser = new IgnoreWhitespaceParser();
parser.setEntityResolver( (fEntityResolver != null)? (fEntityResolver):(new Resolver()) );
parser.setErrorHandler( new ErrorHandler()
{
public void fatalError(SAXParseException ex) throws SAXException {
StringBuffer str = new StringBuffer();
String systemId_ = ex.getSystemId();
if (systemId_ != null) {
int index = systemId_.lastIndexOf('/');
if (index != -1)
systemId_ = systemId_.substring(index + 1);
str.append(systemId_);
}
str.append(':').append(ex.getLineNumber()).append(':').append(ex.getColumnNumber());
String message = ex.getMessage();
if(message.toLowerCase().trim().endsWith("not found.")) {
System.err.println("[Warning] "+
str.toString()+": "+ message);
} else { // do standard thing
System.err.println("[Fatal Error] "+
str.toString()+":"+message);
throw ex;
}
}
});
try {
parser.setFeature("http://xml.org/sax/features/validation", false);
parser.setFeature("http://xml.org/sax/features/namespaces", true);
parser.setFeature("http://apache.org/xml/features/dom/defer-node-expansion", false);
parser.setFeature("http://apache.org/xml/features/continue-after-fatal-error", true);
}catch( org.xml.sax.SAXNotRecognizedException e ) {
e.printStackTrace();
}catch( org.xml.sax.SAXNotSupportedException e ) {
e.printStackTrace();
}
try {
parser.parse( source );
}catch( IOException e ) {
e.printStackTrace();
}catch( SAXException e ) {
//e.printStackTrace();
}
Document document = parser.getDocument(); //Our Grammar
Element root = null;
if (document != null) {
root = document.getDocumentElement();
}