2006 JR Open Discussion Posted August 22, 2006 Share Posted August 22, 2006 By: slowfinger - slowfinger nestings subreports and xml data source 2006-03-20 22:57Hi All, I posted already to the same subject some days ago, but nobody helps so I want to try it again. I want to describe it a bit more detailed ... What I want is to output data which are not in flat hierarchy instead the report contains main data and referenced data which are 1 to n related. I use xml data source. A short example follows: <Problemwurzel> <StandardberichtProblemVO> <Problem> <Problemdatum></Problemdatum> <ProblemKurztext></ProblemKurztext> </Problem> <Bearbeitungsschritte> <StandardberichtBSAnalyseVO> <BearbeitungTs> 2005-03-09 15:28:51.907652 </BearbeitungTs> <Bemerkung> <Text>Analyse Text</Text> </Bemerkung> </StandardberichtBSAnalyseVO> <StandardberichtBSMassnahmeVO> <VorgBearbTs> 2005-03-09 15:28:51.907652 </VorgBearbTs> <SollEinsatz>22.10.2005</SollEinsatz> <DurchfuehrDatum>13.03.2006</DurchfuehrDatum> <Bemerkung> <Text>Massnahme 1</Text> </Bemerkung> </StandardberichtBSMassnahmeVO> <StandardberichtBSMassnahmeVO> <VorgBearbTs> 2005-03-09 15:28:51.907652 </VorgBearbTs> <SollEinsatz>01.03.2006</SollEinsatz> <DurchfuehrDatum>14.03.2006</DurchfuehrDatum> <Bemerkung> <Text>Massnahme 2</Text> </Bemerkung> </StandardberichtBSMassnahmeVO> </Bearbeitungsschritte> </StandardberichtProblemVO> </Problemwurzel> The relation between <StandardberichtBSAnalyseVO> and <StandardberichtBSMassnahmeVO> is 1 to n and is defined by timestamps: /StandardberichtBSMassnahmeVO/VorgBearbTs -> StandardberichtBSAnalyseVO/BearbeitungTs The root path which I use for the main report is as follows: /Problemwurzel/StandardberichtProblemVO The report structure looks as follows: - the main report which reference problem data: Problem/Problemdatum and so forth -- a subreport with dataSourceExpression: ((net.sf.jasperreports.engine.data.JRXmlDataSource) $P{REPORT_DATA_SOURCE}).subDataSource("/StandardberichtProblemVO/Bearbeitungsschritte/StandardberichtBSAnalyseVO") subreportExpression: "analyse.jasper" -- the report "analyse.jasper" contains the analyse text (Bemerkung/Text) and another subreport which should list <StandardberichtBSMassnahmeVO> elements, that I do with dataSourceExpression: dataSource("/Problemwurzel/StandardberichtProblemVO/Bearbeitungsschritte/StandardberichtBSMassnahmeVO[VorgBearbTs=" + $F{analyseBearbeitungTs} + "]") subreportExpression: "massnahme.jasper" That subreport reference the massnahme elements: SollEinsatz, DurchfuehrDatum, Bemerkung/Text My problem is now the massnahme data will not be displayed and I can't say why. So I need your help. How can I do that? Thanks in forward Rico By: slowfinger - slowfinger RE: nestings subreports and xml data source 2006-03-21 09:19Hi, I really really need help on this subject and it seems that it should work but not on me. c-box wrote that it's working fine and mostly its because of wrong datasource expressions. But it would really help if one of that short answers show a short example. Please help I think it wouldn't help only me. Thanks in forward Rico By: Lucian Chirita - lucianc RE: nestings subreports and xml data source 2006-03-21 09:33Hi When you do subDataSource("..") in the first report, a document is created having as root node this report's current node (/Problemwurzel/StandardberichtProblemVO) and this document is used by the second report. Therefore, in the second report StandardberichtProblemVO is the root node so when you instantiate the third report you should not use "/Problemwurzel/StandardberichtProblemVO/.." but "/StandardberichtProblemVO/..". HTH, Lucian By: slowfinger - slowfinger RE: nestings subreports and xml data source 2006-03-21 22:58Hi Lucian, thanks for your answer. I tried your suggestion but it doesn't help. I debugged the code and stepped into jasper sources and what I wonder is that the second call for dataSource() of the nested subreport will never be called. What could be the reason for that. Rico By: Lucian Chirita - lucianc RE: nestings subreports and xml data source 2006-03-22 00:27I don't have any clue. It worked for me with your xml data after making the change I mentioned in my previous post. Regards, Lucian By: slowfinger - slowfinger RE: nestings subreports and xml data source 2006-03-22 01:51Thanks, yes it works. What I've done that it works was a really short master which contains only the subreport. That I called from iReport with the data source and it works. You are correct. Now I have to evaluate what the difference is between my original report when I call it from java. Thanks again Rico By: slowfinger - slowfinger RE: nestings subreports and xml data source 2006-03-28 08:54I found the problem. It's the subreports which I pass as a Map to the parameter map of Jasper. If I use a subreport in an subreport I have to pass the subreports as a subreport parameter and it works like expected. Rico Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now