logger.debug("XmlDocumentReader: Null Document name passed in, can't initialize.");
return null;
}
Document doc = null;
try {
SAXBuilder builder = new SAXBuilder(false);
if (validate == false) {
logger.debug("Setting the EntityResolver to IgnoreDTDResolver.");
builder.setEntityResolver(new IgnoreDTDResolver());
}
else {
logger.debug("Using the default EntityResolver.");
}
if (fileName.toLowerCase().indexOf("http") == 0 || fileName.toLowerCase().indexOf("file") == 0) {
// build from url
logger.debug("Building document from " + fileName);
java.net.URL url = null;
try {
url = new java.net.URL(fileName);
}
catch (Exception e) {
logger.fatal(e.getMessage(), e);
throw new XmlDocumentReaderException(e.getMessage(), e);
}
// logger.info("Started - SAXBuilder.build for URL " + fileName);
doc = builder.build(url);
// logger.info("Ended - SAXBuilder.build for URL " + fileName);
}
else {
// build from file
// logger.info("Started - SAXBuilder.build for file " + fileName);
doc = builder.build(new File(fileName));
// logger.info("Ended - SAXBuilder.build for file " + fileName);
}
logger.debug("XmlDocumentReader:" + fileName + ":successfully read!");
if (validate) {
XmlValidator xmlValidator = new XmlValidator();