genx Posted September 19, 2007 Share Posted September 19, 2007 I have the following xml:<ROOT><INFO></INFO><!--Whole bunch of other nodes --><!--and then this is the problem area --><COMMENTS><TYPE>atype</TYPE><COMMENT>Comment1</COMMENT><COMMENT>Comment2</COMMENT><!--Could have more comments --></COMMENTS></ROOT> I have a master report and a subreport for the COMMENTS.In the Subreports I have the following settingsConnection/DataSource expression - ((net.sf.jasperreports.engine.data.JRXmlDataSource)$P{REPORT_DATA_SOURCE}).dataSource("/ROOT/COMMENTS")Subreport expression - "Comments.jasper". In the Comments.jrxml, I have a single textfield pointing to FieldName:COMMENT, Type:java.lang.String and Description:COMMENT With these settings the report displays just the first comment.I tried changing the DataSource expression to "/ROOT/COMMENTS//COMMENT", the subreport shows 2 rows but with values as null. Appreciate any help! Thanks in advance. Link to comment Share on other sites More sharing options...
lucianc Posted September 20, 2007 Share Posted September 20, 2007 Use "/ROOT/COMMENTS/COMMENT" as XPath for the subreport and "." (or "self::COMMENT", or "self::node()", or "self::text()" and so on) as field description. HTH,Lucian Link to comment Share on other sites More sharing options...
genx Posted September 22, 2007 Author Share Posted September 22, 2007 That worked. Thanks for your help. I have another quick question regarding passing parameter in Datasource expression. <ROOT><INFO><ID>1</ID><!-- more nested nodes --><DATA><VALUE>x</VALUE><RESULT>blah</RESULT></DATA><COMMENTS><TYPE>infotype</TYPE><COMMENT>Commentid1</COMMENT></COMMENTS></INFO><INFO><ID>2</ID><!-- more nested nodes --><DATA><VALUE>y</VALUE><RESULT>blah y</RESULT></DATA><COMMENTS><TYPE>infotype</TYPE><COMMENT>Commentid2</COMMENT></COMMENTS></INFO><COMMENTS><TYPE>atype</TYPE><COMMENT>Comment1</COMMENT><COMMENT>Comment2</COMMENT><!--Could have more comments --></COMMENTS></ROOT> I have a INFO subreport which has a COMMENTS subreport.INFO subreport has:parameter ID (passed from master report):Report Query : /ROOT/INFO[iD=$P{ID}]/DATA:COMMENTS subreport - Datasource expression : ((net.sf.jasperreports.engine.data.JRXmlDataSource)$P{REPORT_DATA_SOURCE}).dataSource("/ROOT/INFO[iD=$P{ID}]/COMMENTS/COMMENT")This does not display the comments. However if I hardcode the ID ((net.sf.jasperreports.engine.data.JRXmlDataSource)$P{REPORT_DATA_SOURCE}).dataSource("/ROOT/INFO[iD=1]/COMMENTS/COMMENT"), the comments are displayed. Is passing parameter allowed? If not how can I pass a parameter to the nested subreport? ThanksIvy 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