XML subreport problem

Hi, ive proglem with creating subreports using xml datasource. I ve got this xml:
<root>
<user>
<name>John</name>
<hobbies>
<hobby>skiing</hobby>
<hobby>cykling</hobby>
</hobbies>
</user>
<user ...>
...
</root>

I want to print hobbies using subreport. First I created master report with Report query: /root/user . In master report user names (field name/text()) are shown (generated in output file) with now problem. Next I created subreport in detail section with Datasource expression: hobbies*hobby (or ((net.sf.jasperreports.engine.data.JRXmlDataSource)$P{REPORT_DATA_SOURCE}).subDataSource("hobbies") ) and in subreport I created field hobby/text(), but nothing is shown in subreport. I tried these subreport field values: hobbies/hobby/text() or just text() but nothing works. Only user names are shown. Thanks a lot for helping me.
I'm working on a similar scenario at the moment. :)

The XML data source example with Jasper Reports passes a parameter to the sub report which is used in the XPATH query to set context. eg:
<parameter name="CurrentUser" class="java.lang.String"/>

/root/user[name='$P{CurrentUser}']/hobbies

... or something along those lines might work for you.

Ideally you should be able to push a the data down (for the current context) to the sub report (as I think you are trying to do) but I havent found a good example of how to do this. If you come up with one, let me know! :)
This topic is archived Other recent topics