views:

3557

answers:

1

Hello,

I am using iReport 3.5.2 to create a report using an XML data source. I followed the "Step by step" example from the "Sub-reports" section of "The Ultimate Guide to iReport", and I was able to get the example working with SQL. However, when I try to use an XML data source and XPath, the sub-report comes out blank in the master report's rendition (though it renders fine by itself).

What I am doing is fairly straight-forward:

  • I create a master report
  • I place a sub-report into it which passes a parameter with a value like "/Foo/Bar" (the XPath for the particular list of data I want in the sub-report)
  • I place a field in the sub-report which references this XPath using $P{}

Again, I can render the sub-report alone and enter a parameter value like "/Foo/Bar" and the report will render as anticipated. I have tried removing XPath from the equation all together and simply creating a field with the parameter value, and still I get a blank page. This makes me suspect that something deeper than XML/XPath is wrong.

Thank you! Sean Purser-Haskell, Kewill PLC

+2  A: 

I came across your post and share your pain. I was in the exact same situation. The code in the iReport/XML datasource/sub report tutorial is broken. I found this on the jasper forums and it solved my issues. Essentially, the datasource expression used in the example is wrong, you need to replace it with an xpath query for the report items of the subreport. something like this:

((net.sf.jasperreports.engine.data.JRXmlDataSource)$P{REPORT_DATA_SOURCE}).subDataSource("//YOUR_SUBREPORT_ENTITY")

http://jasperforge.org/plugins/espforum/view.php?group_id=83&forumid=101&topicid=48534

revdrjrr