SAXParser parser = factory.newSAXParser();
reader = new SAXReader(parser.getXMLReader());
} catch (SAXException e) {
throw new ReportingXmlException(String.format("An error occurred during loading reporting xsd. \\n[%s]", xml), e);
} catch (ParserConfigurationException e) {
throw new ReportingXmlException(String.format("An error occurred during loading reporting xsd. \\n[%s]", xml), e);
}
Document document = reader.read(new StringReader(xml));
Element rootElement = document.getRootElement();
Map<String, ReportTemplate> templateMap = parseTemplates(rootElement);
List<ReportParameter> reportParameters = parseInputParameters(rootElement);
List<ReportFieldFormat> reportFieldFormats = parseValueFormats(rootElement);
BandBuilder rootBandDefinitionBuilder = new BandBuilder().name(BandData.ROOT_BAND_NAME);
parseChildBandDefinitions(rootElement.element("rootBand"), rootBandDefinitionBuilder);
ReportBand rootBandDefinition = rootBandDefinitionBuilder.build();
String reportName = rootElement.attribute("name").getText();
ReportImpl report = new ReportImpl(reportName, templateMap, rootBandDefinition, reportParameters, reportFieldFormats);
return report;
} catch (DocumentException e) {
throw new ReportingXmlException(String.format("An error occurred while parsing report xml. \\n[%s]", xml), e);
} catch (FileNotFoundException e) {
throw new ReportingXmlException(String.format("Could not find report template. \\n[%s]", xml), e);
} catch (ClassNotFoundException e) {
throw new ReportingXmlException(String.format("Report parameter class not found. \\n[%s]", xml), e);
}
}