I want to compile a .JRXML file with an XML Datasource in Java. It works perfectly within iReport. In Java, it does not work.
When I set the main query language to 'xpath', the report is generated, but with no xml data in it.
With 'xpath2' as the main query language, I get an error "No query executer factory registered for the 'xpath2' language" and the report is not being generated.
It doesn't even work with the simplest report you can think of.
What I've tried so far:
My report generation code:
JasperReport jasperReport = JasperCompileManager.compileReport(args[0]);
JasperPrint jasperPrint = JasperFillManager.fillReport(jasperReport, params, new JREmptyDataSource());
JasperExportManager.exportReportToPdfFile(jasperPrint, args[1]);
After adding jasper-compiler-jdt-5.5.23.jar to my Java Build Path, I got rid of the xpath2 error. The report is generated, but with no data source.
It now works with an xpath datasource. I created the datasource in my Java application instead of passing the XML_URL. It's not perfect, but a good workaround. This is the code I used:
org.w3c.dom.Document document = JRXmlUtils.parse(JRLoader.getLocationInputStream("/file/location.xml"));
JasperPrint jasperPrint = JasperFillManager.fillReport(jasperReport, params, new JRXmlDataSource(document, "/xpath"));