Home » Archived » BIRT » help with XML datasource(help)
help with XML datasource [message #806226] |
Fri, 24 February 2012 18:19 |
santiago m Messages: 4 Registered: January 2012 |
Junior Member |
|
|
Hi! Here is some trouble that I have, trying to use an XML datasource:
I have a report datasource(we now will call him "MasterDS") that connects to a data base, and one of the data I want to get, is a string that is formatted like an XML file (really is an XML file, but for performance issues, I save it in the DB like a string).
So far all good, but the problem appears with that XML string, when I want to put some of the attributes of that xml in a table on the report.
One way to do that that I'm trying is:
Creating an XML-data-source with that string XML that is obtained in execution time from a select query. But here comes the question:
Can I create an XML-datasource based on a string instead of a file?? and if I can...
Can I create an XML-datasource at runtime of the report, after getting the string(XML) from a query on the "MasterDS" datasource?
I ask this because I wanted to use the functionality of xml-datasource provided by birt, other way, I think, can be using a parser of XML in a script, after getting the String XML from a query,but is more complex...
I hope you have understood the problem I have, and any help is good!
Thanks!!
|
|
|
Re: help with XML datasource [message #807614 is a reply to message #806226] |
Sun, 26 February 2012 19:37 |
santiago m Messages: 4 Registered: January 2012 |
Junior Member |
|
|
Hi, it´s me again... I saw in the internet, that there is an option of doing this with an imputStream.
If I get the String that has the XML desired, in the time of creation of the DataSources, I can put it in a ByteArrayImputStream and "pass it" to the XML datasource, using the Application Context, but I don´t know how to do it well... because all the examples I saw, they did it through the use of the API and coding, but I will use the BIRT web viewer to show that reports in the web.
so I think that I can pass it using a Script, in the beforeOpen of the XML datasource can be? If is there, how can I get the applicationContext map to put the inputStream that I created(with the XML), for be used by the XML Datasource.
hoping an answer
Santiago
|
|
|
Re: help with XML datasource [message #808485 is a reply to message #807614] |
Mon, 27 February 2012 20:50 |
|
Why not just get the xml string from the db and then parse the tag you
need in the data expression. Have a look at the attached example.
Jason
On 2/26/2012 2:37 PM, santiago m wrote:
> Hi, it´s me again... I saw in the internet, that there is an option of
> doing this with an imputStream.
> If I get the String that has the XML desired, in the time of creation of
> the DataSources, I can put it in a ByteArrayImputStream and "pass it" to
> the XML datasource, using the Application Context, but I don´t know how
> to do it well... because all the examples I saw, they did it through the
> use of the API and coding, but I will use the BIRT web viewer to show
> that reports in the web.
>
> so I think that I can pass it using a Script, in the beforeOpen of the
> XML datasource can be? If is there, how can I get the applicationContext
> map to put the inputStream that I created(with the XML), for be used by
> the XML Datasource.
> hoping an answer
> Santiago
|
|
| |
Re: help with XML datasource [message #809588 is a reply to message #809404] |
Wed, 29 February 2012 02:40 |
|
If you are running this through the viewer you could add it to session
and read it from session:
reportContext.getHttpServletRequest().getSession().setAttribute("myattr","myattval");
reportContext.getHttpServletRequest().getSession().getAttribute("myattr");
BTW I attached a report that shows how to set the stream in the
beforeOpen of the data set.
Jason
On 2/28/2012 3:55 PM, santiago m wrote:
> yes! that was one of the ideas I had... but analyzing well, the XML I
> have is complex, so I thought doing this, using a query on an
> XML-datasource that is based on the string that has the XML.
> I create the XML data source based on a string, but my question now is:
>
> how can I pass an object(a String that is the result of a query) from
> one report to another?? without using a parameter to a page... I saw
> that I can use the application Context to put the string there, but in
> the other report, how can I get it??
>
> thank you very much for the answer you gave me!
|
|
|
Goto Forum:
Current Time: Tue Sep 24 11:25:44 GMT 2024
Powered by FUDForum. Page generated in 0.02608 seconds
|