Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
PUBLIC CLOUD
PRIVATE CLOUD
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Intelligence (Analytics)
Streaming multiple xml in application
Mr.Reed
Hi there,<br />
<br />
i am using Birt 2.6 in a web-application.<br />
Furthermore i generate a xml at runtime and pass it to my report like this:<br />
<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>InputStream myInputStream = new ByteArrayInputStream(reportContents.getBytes());
contextMap.put("org.eclipse.birt.report.data.oda.xml.inputStream", myInputStream);
contextMap.put("org.eclipse.birt.report.data.oda.xml.closeInputStream", true);</pre>
<br />
Since i can define more than one xml data sources in my report, can i stream more than one xml data source?<br />
I found the following code, but couldn't figure how to adapt it to my problem:<br />
<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>mDesign = mEngine.openReportDesign(designFile);
ReportDesignHandle reportDesignHandle = (ReportDesignHandle) mDesign.getDesignHandle();
SlotHandle datasourceSlotHandle = reportDesignHandle.getDataSources();
OdaDataSourceHandle dataSource = null;
if (datasourceSlotHandle.getCount() > 0) {
dataSource = (OdaDataSourceHandle) (datasourceSlotHandle.get(0));
dataSource.setProperty("FILELIST", <absolute-path-to-xml-file>);
}</pre>
<br />
It seems like dataSource.setProperty is not applicable for inputstream.<br />
<br />
Is there maybe another way?<br />
<br />
Thanks in advance...
Find more posts tagged with
Comments
JasonW
You could add two xml datasources and one dataset for each and set the stream in the beforeOpen of the dataset. See attached example. Change both datasources to point to a dummy xml file. The beforeOpen dataset has the code to set values.
Jason
JasonW
Forgot the report.
Mr.Reed
Hi Jason,
thanks for your reply.
So if i get your solution right, i am defining an inputstream per data set?
Your "beforeOpen"-script defines an manual inserted inputstream. But i pass an inputstream via my application, so defining the inputstream in the "beforeOpen"-script would become obsolet, wouldn't it?
But how can i tell the "beforeOpen"-Script to use the inputstream from the application? Or do i have to do that in programmatically?
Thanks...
JasonW
You could in your code put something like:
task.getAppContext().put("stream1", createdstream1);
task.getAppContext().put("stream2", createdstream2);
Then modify the beforeOpen script to set the value like
appcon = reportContext.getAppContext();
var bais = appcon.get("stream1");
appcon.put("org.eclipse.datatools.enablement.oda.xml.inputStream", bais);
Jason
bilred
<div>Hello,</div><div>I want to do the same thing (I did not understand your solution or suggestion)</div><div>You can send me a sample source code complete with ". Rptdesign"</div><div> </div><div>Or if you know a tutorial that explains how to do this it would be ideal if you transmettes us on the topic.</div><div> </div><div>Big thank you in advance.</div>
mwilliams
<p>What Jason is saying is that when you're setting up your engine task to execute your BIRT design, you can pass your two xml streams through the app context with the code he added above. Then, in the xml datasets that you've defined, you can grab the stream from the app context in the beforeOpen script.</p><p> </p><p>Hope this helps.</p>
thomasjbake
<p>JasonW, you are one Steely Eyed Missile Man! I used your appContext trick, but I had to put it in afterOpen on each dataset to work with my joint data set. Otherwise the inputStream kept getting overridden. After that it worked like a charm.</p>
<p>Thank you sir!</p>