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

HOWTO:Master-Detail with nested Objects XML File


raja_s_patil

Recommended Posts

Hi,

I have successfully created master detail report with a XML file containing nested Objects.

I am beginer with iReport and purpose of the post is to help other beginers like me. I am attaching

reuired files herewith for ready reference. here goes the step by step description.

  1. Create a master report.
  2. In master report define a datasource pointing to XML file attached.
  3. Open Query dialogue and select xpath2. Set /root as document root and /root/VOPurchaseOrder as record node.
  4. Define necessary fields and place them on master report and test the report in preview.
  5. If above thing works fine then proceed further.
  6. Drag subreport and place it on detail band of master report. I skipped all steps in the wizard but u can answer those options.
  7. select subreport in master report and go to proerties pane.
  8. in subsection subreport properties->connection Type select useDataSourceExpression.
  9. in sunsection subreport Properties->DataSourceExpression enter ((net.sf.jasperreports.engine.data.JRXmlDataSource)$P{REPORT_DATA_SOURCE}).subDataSource("/VOPurchaseOrder/array_items/VOPOItemRef") Not That this is very important
  10. Note that we have selected /root/VOPurchaseOrder as record node for master report and /VOPurchaseOrder/array_items/VOPOItemRef as subdatasource. This makes only nested VOPOItemRef objects for current record in master report are selected for subreport datasource and this is what is expected. I have stumbled on this step since i started learning iReport. Ths is very crucial concept of subdatasources which takes little bit of time to digest for newcommers in XML and XPATH area.
  11. After this the life is normal. Select subreport tab in main editor window and select query definition dialogue.
  12. in this dialogue set /root/VOPurchaseOrder as document root since Mater report is using it as record set.
  13. Then define /VOPurchaseOrder/array_items/VOPOItemRef as recordset node for subreport. donot forget to select xpath2
  14. Then define fields and populate the detail band.
  15. save detail report and compile it.
  16. select master report in editor tab and run it. If all have gone well u will see report otherwise debug it.

If u have some queries about this example ask freely in this thread.

Since I am a biginner in iReport I may not be able solve some tricky XML docs but I will

take some efforts to help u out as I could.

Thanks and best regards.

Raja.

 

 



Post Edited by raja_s_patil at 07/26/2009 09:02
Link to comment
Share on other sites

  • Replies 1
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

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...