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

subreport and XML source


pw_inf

Recommended Posts

Hi

I have read many posts on previous iR. forum, but still I have problem with creating report with subreports: all based on the same xml file.

I don't have to create any "live relation" between report and subreports - I need only put particular subset from XML file in subreport and place title field in report.

It doesn't work regardless of choosen connection type - I getting blank space in subreport place (subreport run as standalone working good).

I messed with different querries for report and subreport, and with one querry defined along with source definition. What should I do if i have working report and standalone warking subreport to merge this reports together?

Link to comment
Share on other sites

  • Replies 5
  • Created
  • Last Reply

Top Posters In This Topic

  • 2 years later...

Hi,

I am new to jasper reports. I am trying to use subreports with xml as datasource.

I specified the datasource for my subreport it worked. Thanks for your information.

 

I want to know, how to select a particular list of nodes in the datasource.

((net.sf.jasperreports.engine.data.JRXmlDataSource)$P{REPORT_DATA_SOURCE}).dataSource(/root/child[name=$P{ChildName}]/info)

I tried this but this didn't help me. In the subReport I have specified my xpath directory as (/root/child[name=$P{ChildName}]/info

 

I have passed the parameter ChildName. Here is my sample xml for your understanding. Please let me know how to get this subreprot.

 

<root>

 <child>

<name>TEST</name>

<info>1</info>

<info>2</info>

<info>3</info>

</child>

</root>

 

Link to comment
Share on other sites

  • 1 year later...

I am cotinuing this thread as I have similar issue...any help is appreciated...I am new to jasper report....

I am creating a master report pointing to a XML datasource and sub report pointing to the Same datasource. When I run the report I get the following error. How do I connect the sub report to a XML datasource.

Sub report properties that I have setup is the following.

Connection type = Use a connection expression
Connection Expression = ((net.sf.jasperreports.engine.data.JRXmlDataSource) $P{REPORT_DATA_SOURCE}).dataSource("/Northwind/Customers")

Error:

Caused by: java.lang.ClassCastException: net.sf.jasperreports.engine.data.JRXmlDataSource cannot be cast to java.sql.Connection     at MasterReport_1289663361627_802700.evaluate

Stack Trace:
Error filling print... Error evaluating expression :      Source text : ((net.sf.jasperreports.engine.data.JRXmlDataSource) $P{REPORT_DATA_SOURCE}).dataSource("/Northwind/Customers")
java.lang.NoSuchMethodException: net.sf.jasperreports.engine.JasperReport.<init>(java.lang.String)     at java.lang.Class.getConstructor0(Class.java:2706)     at java.lang.Class.getConstructor(Class.java:1657)     at com.jaspersoft.ireport.designer.compiler.prompt.Prompter$1.run(Prompter.java:230)     at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:199)     at java.awt.EventQueue.dispatchEvent(EventQueue.java:597)     at org.netbeans.core.TimableEventQueue.dispatchEvent(TimableEventQueue.java:104)     at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:269)     at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184)     at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:174)     at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169)     at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161)     at java.awt.EventDispatchThread.run(EventDispatchThread.java:122) net.sf.jasperreports.engine.fill.JRExpressionEvalException: Error evaluating expression :      Source text : ((net.sf.jasperreports.engine.data.JRXmlDataSource) $P{REPORT_DATA_SOURCE}).dataSource("/Northwind/Customers")     at net.sf.jasperreports.engine.fill.JREvaluator.evaluate(JREvaluator.java:195)     at net.sf.jasperreports.engine.fill.JRCalculator.evaluate(JRCalculator.java:589)     at net.sf.jasperreports.engine.fill.JRCalculator.evaluate(JRCalculator.java:557)     at net.sf.jasperreports.engine.fill.JRFillElement.evaluateExpression(JRFillElement.java:929)     at net.sf.jasperreports.engine.fill.JRFillSubreport.evaluateSubreport(JRFillSubreport.java:332)     at net.sf.jasperreports.engine.fill.JRFillSubreport.evaluate(JRFillSubreport.java:263)     at net.sf.jasperreports.engine.fill.JRFillElementContainer.evaluate(JRFillElementContainer.java:258)     at net.sf.jasperreports.engine.fill.JRFillBand.evaluate(JRFillBand.java:499)     at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillColumnBand(JRVerticalFiller.java:2033)     at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillDetail(JRVerticalFiller.java:760)     at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReportStart(JRVerticalFiller.java:270)     at net.sf.jasperreports.engine.fill.JRVerticalFiller.fillReport(JRVerticalFiller.java:128)     at net.sf.jasperreports.engine.fill.JRBaseFiller.fill(JRBaseFiller.java:946)     at net.sf.jasperreports.engine.fill.JRFiller.fillReport(JRFiller.java:118)     at net.sf.jasperreports.engine.JasperFillManager.fillReport(JasperFillManager.java:435)     at net.sf.jasperreports.engine.JasperFillManager.fillReport(JasperFillManager.java:271)     at com.jaspersoft.ireport.designer.compiler.IReportCompiler.run(IReportCompiler.java:989)     at org.openide.util.RequestProcessor$Task.run(RequestProcessor.java:572)     at org.openide.util.RequestProcessor$Processor.run(RequestProcessor.java:997) Caused by: java.lang.ClassCastException: net.sf.jasperreports.engine.data.JRXmlDataSource cannot be cast to java.sql.Connection     at MasterReport_1289663361627_802700.evaluate(MasterReport_1289663361627_802700:189)     at net.sf.jasperreports.engine.fill.JREvaluator.evaluate(JREvaluator.java:182)     ... 18 more
Print not filled. Try to use an EmptyDataSource

Link to comment
Share on other sites

  • 3 weeks later...
  • 8 years later...

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