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

how to set up a subreport using an xml datasource


ronatartifact

Recommended Posts

I am trying to draw a purchase order with a few subreports to display things like Bill to and Ship to addresses as well as item lines.

I can not figure out how to specify the connection of the data source from the main report to the sub reports in the right way

It can not be that complicated but I have not been able to figure it out from the documentation that I have found.

 

Thanks

Ron



Post Edited by ronatartifact at 09/11/2009 12:21



Post Edited by ronatartifact at 09/11/2009 12:22
Link to comment
Share on other sites

  • Replies 3
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

XML Datasources work on the XML standards so you simply need to point your datasource at the root of your XML datafile. Then move the cursor position to the correct node to output the data.

Also you need to add the tag name to the Description property of the Field element.

Your datasource to get the data and make it all work will depend on the complexity of your XML datafile and your xPath statement, Which is all garbled above. upload a file!

Suggest you have a look at the example that ships with jasperReports and have a look at xPath tutorial here :

http://www.w3schools.com/XPath/default.asp

Luck!



Post Edited by walmillard at 09/11/2009 06:10
Link to comment
Share on other sites

I actually found a sample chapter from one of the books on iReports that actually described a good part of the process.

http://books.google.ca/books?id=GeLCEnT1VpMC&pg=PA157&lpg=PA157&dq=ireports+jrxmldatasource+example&source=bl&ots=abW5BGl9G2&sig=ncpr7vEI2QZJfOLe3gJSN5d7vE4&hl=en&ei=dn2pSuvhHoqlnQecjvgY&sa=X&oi=book_result&ct=result&resnum=7#v=onepage&q=&f=false

 

I also found an out of date manual which was helpful.

http://ireport.sourceforge.net/cap7.html  was the most helpful document but it glossed over the key information about how to link up the fields between the  sub-reports and the main report.
By a bit of testing and reading between the lines, I figured out what the actual code had to be.
If it had 2 more sentences and two code fragments, it would have solved my problem at first reading.

The sample chapter (first reference above) supplied the information that the last reference lacked.

I have attached my working code and data for anyone who finds this thread and wants a working solution.

The report is still underconstruction but the bits that are there, work.

 



Post Edited by ronatartifact at 09/11/2009 12:57



Post Edited by ronatartifact at 09/11/2009 15:40
Link to comment
Share on other sites

ronatartifact,

 

The Google Books link is interesting. (It's out of date compared to what's available on jaspersoft.com, but I don't think that piece hasn't changed.)

 

The scribd link is the entire copy of a copyrighted book. Using 233 of 233 does fall under fair use principles. It's a clear copyright violation. Would you mind removing the link to it?

 

Regards,
Matt

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