Subreport cascade with XML Datasource

0

Hi all,

I'm not able to solve really simple problem.  How can I iterate over List in SubReport included from another Subreport ?

XML Example :

<xmldata>

   <group> 

      <group><position></position></group>

      <group><position></position></group>

   </group>

   <group> 

      <group><position></position></group>

      <group><position></position></group>

   </group>

</xmldata>

Mainreport

<queryString language="xPath">
   <![CDATA[/xmldata/group]]>
</queryString>
<detail>

...

<subreport>
<dataSourceExpression><![CDATA[((net.sf.jasperreports.engine.data.JRXmlDataSource)$P{REPORT_DATA_SOURCE}).subDataSource("/group/group")]]></dataSourceExpression>
<subreportExpression><![CDATA[$P{SUBREPORT_DIR} + "reportGroup.jasper"]]></subreportExpression>
</subreport>

</detail>

Subreport reportGroup works ... :

<detail>

..

<subreport>
<subreportExpression><![CDATA[$P{SUBREPORT_DIR} + "reportPosition.jasper"]]></subreportExpression>
</subreport>

</detail>

reportPosition has detail section to show all positions of a Group...

Now we got Groups and Groups of groups in Report. OK. Positions is emtpy every time.

Everything works Fine in iReport, Jasper Studio and as Java Application . Groups, Groups og Groups and Positions are printed.

Now I try to show Positiosn of every Group ...

I add following in reportGroup :

<dataSourceExpression><![CDATA[((net.sf.jasperreports.engine.data.JRXmlDataSource)$P{REPORT_DATA_SOURCE}).subDataSource("/group/position")]]></dataSourceExpression>

It works in iReport and in Jasper Studio. BUT does not work as Java Application. With following error:

[http-nio-8081-exec-6] net.sf.jasperreports.engine.fill.JRFillSubreport.prepare Fill 1: exception
net.sf.jasperreports.engine.fill.JRExpressionEvalException: Error evaluating expression for source text: ((net.sf.jasperreports.engine.data.JRXmlDataSource)$P{REPORT_DATA_SOURCE}).subDataSource("/group/position")
at net.sf.jasperreports.engine.fill.JREvaluator.handleEvaluationException(JREvaluator.java:284)
at net.sf.jasperreports.engine.fill.JREvaluator.evaluate(JREvaluator.java:316)

Could somebody explain me , why?

I tried JREmptyDataSource, just to be sure... wit works in iReport, and Studio but not in Java Application

[http-nio-8081-exec-7] net.sf.jasperreports.engine.fill.JRFillSubreport.prepare Fill 1: exception
net.sf.jasperreports.engine.fill.JRExpressionEvalException: Error evaluating expression for source text: new JREmptyDataSource()
at net.sf.jasperreports.engine.fill.JREvaluator.handleEvaluationException(JREvaluator.java:284)

I tried to pass XML Document like this

parameters.put(JRXPathQueryExecuterFactory.PARAMETER_XML_DATA_DOCUMENT, document); JasperFillManager.fillReport("<path...>/mainReport.jasper", parameters);

and like this

JRXmlDataSource jr = new JRXmlDataSource(document,"/xmldata/group");
JasperFillManager.fillReport("<path...>/mainReport.jasper", parameters, jr);

So it schould be a problem to pass Datasource from Details section in subreport to another subreport.

Actually really simple and standard issue or not?

Regards Leo

see also https://community.jaspersoft.com/questions/1141426/problem-passing-datasource-one-subreport-another-subreport

bikerpfanne's picture
Joined: Aug 4 2019 - 10:14am
Last seen: 4 weeks 1 day ago

0 Answers:

No answers yet
Feedback