[英]XML Datasource in report is not working
I want to compile a .JRXML file with an XML Datasource in Java. 我想用Java中的XML数据源编译.JRXML文件。 It works perfectly within iReport .
它可以在iReport中完美运行。 In Java, it does not work.
在Java中,它不起作用。
When I set the main query language to 'xpath', the report is generated, but with no xml data in it. 当我将主要查询语言设置为“ xpath”时,将生成报告,但其中没有xml数据。
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. 使用'xpath2'作为主要查询语言时,出现错误“没有为'xpath2'语言注册工厂查询执行器”,并且未生成报告。
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. 将jasper-compiler-jdt-5.5.23.jar添加到Java构建路径后,我摆脱了xpath2错误。 The report is generated, but with no data source.
报告已生成,但没有数据源。
It now works with an xpath datasource. 现在,它可以与xpath数据源一起使用。 I created the datasource in my Java application instead of passing the XML_URL.
我在Java应用程序中创建了数据源,而不是传递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"));
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.