Jump to content
We've recently updated our Privacy Statement, available here ×

Problem with subreports and XML Datasource


gobenn71

Recommended Posts

Hi all,

 

I've got a problem with a report built upon an xml datasource.

My XML file containing certain trade data has some basic information (e.g. Buyer, Seller, Currency, Amount etc..) and some repeatable interval subsections which contain specific data on certain trades  ( date from., date to and so on...).

 

I created a (main-)report to display the general trade data and created a (sub-)report which displays the trade intervals as a table. Both reports use XPath expressions to define a record node, of course the pathes are different. ( e.g. main report "TradeData", 2nd (sub-)report "TradaDataTimeIntervalsTimeInterval" ...). When run alone, both reports are doing fine.

 

I then tried to incorporate the report displaying the interval data into the main report but then, the sub report is always empty. It never shows any data, even no static text fields.

I suppose that i have a problem with my Datasource, in fact can anyone explain how to set up a sub report datasource-wise when it should use the same datasource as the main report but a different XPath-Expression ?

 

 

 

Link to comment
Share on other sites

  • Replies 3
  • Created
  • Last Reply

Top Posters In This Topic

Let me add that if i switch the 'whenNoDataType ' property of the subreport to 'AllSectionsNoDetail' , i can see the headers containing static text in the main report so the problem is not related to formatting problems or a misplaced subreport or something like that. It must be connected to the XML Datasource .

 

 

 

Link to comment
Share on other sites

Found a solution to my problem.

Seems that i wasn't passing the datasource in the right way to the subreport . In the subreport settings, i set the datasource to ((net.sf-.jasperreports.engine.data.JRXmlDataSource)
$P{REPORT_DATA_SOURCE}).dataSource("/TradeData/TimeIntervals/TimeInterval")

and everything works now.

Link to comment
Share on other sites

  • 6 months later...

Thank you for a valuable information.

I'll add my 5 cents in order to not confuse others.

sf should be without "-", like ((net.sf.jasperreports.engine.data.JRXmlDataSource) $P{REPORT_DATA_SOURCE}).dataSource("/TradeData/TimeIntervals/TimeInterval")



Post Edited by andfedotov at 05/09/2009 18:40
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...