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

XMLDatasource in subreport not displaying all rows


genx

Recommended Posts

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 settings

Connection/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

  • Replies 2
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

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?

 

Thanks

Ivy

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