Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » BIRT » Set a XML DataSource Programmatically
Set a XML DataSource Programmatically [message #346834] Tue, 29 January 2008 08:57 Go to next message
Eclipse UserFriend
Originally posted by: pari.gandhi.gmail.com

Hello World,

Here is what I am trying to do:-

I have created a report called test.rptdesign. I have specified a XSD file
as the datasource of my report and the report's dataset contains the
elements in the XSD schema.

right, now I am want to invoke this report programmatically. I have a Java
Object that I have converted to XML (using JAXB) and I now want to set the
XML as the datasource for this report at runtime.

ie., While design time, I have specified a XSD schema as my datasource,
but while run time I want the report to point to a XML file. Makes sense?
How would I go about doing this?


String xmlString = "<application>.................</application>";
ReportDesignHandle reportDesignHandle = 
(ReportDesignHandle)design.getDesignHandle();
    SlotHandle dataSets = reportDesignHandle.getDataSets();



How can set the xmlString as my dataSource? Any ideas / pointers?

Regards,
Mikey
Re: Set a XML DataSource Programmatically [message #360404 is a reply to message #346834] Tue, 29 January 2008 15:17 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: jasonweathersby.alltel.net

Mikey,

I am a little confused.
Do you want this

>
 >
 > String xmlString = "<application>.................</application>";
 > ReportDesignHandle reportDesignHandle =
 > (ReportDesignHandle)design.getDesignHandle();
 >    SlotHandle dataSets = reportDesignHandle.getDataSets();
 >
 > 


as your data source? Or do you just want to know how to change the xml
source using the api?

Jason

Mikey wrote:
> Hello World,
>
> Here is what I am trying to do:-
>
> I have created a report called test.rptdesign. I have specified a XSD
> file as the datasource of my report and the report's dataset contains
> the elements in the XSD schema.
>
> right, now I am want to invoke this report programmatically. I have a
> Java Object that I have converted to XML (using JAXB) and I now want to
> set the XML as the datasource for this report at runtime.
>
> ie., While design time, I have specified a XSD schema as my datasource,
> but while run time I want the report to point to a XML file. Makes
> sense? How would I go about doing this?
>
>
> 
> String xmlString = "<application>.................</application>";
> ReportDesignHandle reportDesignHandle = 
> (ReportDesignHandle)design.getDesignHandle();
>    SlotHandle dataSets = reportDesignHandle.getDataSets();
> 
> 

>
> How can set the xmlString as my dataSource? Any ideas / pointers?
>
> Regards,
> Mikey
>
Re: Set a XML DataSource Programmatically [message #360406 is a reply to message #360404] Tue, 29 January 2008 15:52 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: pari.gandhi.gmail.com

Jason,

I want to know how to change the XML Source using the API.
Re: Set a XML DataSource Programmatically [message #360409 is a reply to message #360406] Tue, 29 January 2008 16:36 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: jasonweathersby.alltel.net

Mikey,

You should be able to use something like this:

design = engine.openReportDesign("Reports/TopNPercent.rptdesign");

ReportDesignHandle report = (ReportDesignHandle)
design.getDesignHandle( );
report.findElement("NewChart").drop();
OdaDataSetHandle dataSourceHandle =
(OdaDataSetHandle)report.findDataSet("myxmldataset");
dataSourceHandle.setProperty("FILELIST", "C:/temp/xmltest.xml");

Jason

Mikey wrote:
> Jason,
>
> I want to know how to change the XML Source using the API.
>
>
>
Re: Set a XML DataSource Programmatically [message #360417 is a reply to message #360409] Wed, 30 January 2008 03:34 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: pari.gandhi.aec.gov.au

Jason,

Thanks for that. One question though:-

I understand that the "FILELIST" property points to a physical XML File.

dataSourceHandle.setProperty("FILELIST", "C:/temp/xmltest.xml");


But in my case, I have the XML data stored in a string variable.

String appXML = "<application>..............</application>";


How could I use this XML data as my datasource?
Re: Set a XML DataSource Programmatically [message #360422 is a reply to message #360417] Wed, 30 January 2008 16:05 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: jasonweathersby.alltel.net

Mikey,

The xml driver uses the filelist property to open a file. It can also
support an InputStream. In your case that is a little tricky because
you have it in a string. If you put code similar to the following in
the before open script of the xml data set it should work. The code is
a little ugly though.

importPackage( Packages.java.io );
importPackage( Packages.java.lang );

test = "<?xml version=\"1.0\"?>";
test = test + "<library>";
test = test + " <book category=\"COOKING\">";
test = test + " <title lang=\"en\">The American Cook Book</title>";
test = test + " <author name=\"Miguel Ortiz\" country=\"es\"/>";
test = test + " <year>2005</year>";
test = test + " </book>";
test = test + " <book category=\"CHILDREN\">";
test = test + " <title lang=\"en\">Everyone is Super Special</title>";
test = test + " <author name=\"Sally Bush\" country=\"uk\"/>";
test = test + " <year>2005</year>";
test = test + " </book>";
test = test + " <book category=\"AUTOBIOGRAPHY\">";
test = test + " <title lang=\"en\">Japanese Greetings</title>";
test = test + " <author name=\"Taro Yamada\" country=\"uk\"/>";
test = test + " <year>2005</year>";
test = test + " </book>";

test = test + " <book category=\"WEB\">";
test = test + " <title lang=\"en\">Query Kick start</title>";
test = test + " <author name=\"James McGovern\" country=\"us\"/>";
test = test + " <year>2006</year>";
test = test + " </book>";
test = test + " <audio format=\"CD\" category=\"MUSIC\">";
test = test + " <title lang=\"en\">Feels Like Home</title>";
test = test + " <artist name=\"Norah Jones\" country=\"us\"/>";
test = test + " <year>2005</year>";
test = test + " </audio>";
test = test + "</library>";

testJS = new java.lang.String( test );
testbytes = testJS.getBytes();
bais = new ByteArrayInputStream( testbytes );

reportContext.getAppContext().put("org.eclipse.datatools.enablement.oda.xml.inputStream ",
bais );

You will notice that I am using the app context to set the input stream
for the xml driver. This is not needed if using a file or URL.

Jason

Mikey wrote:
> Jason,
>
> Thanks for that. One question though:-
>
> I understand that the "FILELIST" property points to a physical XML File.
>
>
> dataSourceHandle.setProperty("FILELIST", "C:/temp/xmltest.xml");
> 

>
> But in my case, I have the XML data stored in a string variable.
>
>
> String appXML = "<application>..............</application>";
> 

>
> How could I use this XML data as my datasource?
>
>
>
Re: Set a XML DataSource Programmatically [message #360477 is a reply to message #360422] Sat, 02 February 2008 03:56 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: pari.gandhi.gmail.com

Thank you. Worked like a charm
Re: Set a XML DataSource Programmatically [message #1153308 is a reply to message #360422] Thu, 24 October 2013 14:20 Go to previous message
billel redouane is currently offline billel redouaneFriend
Messages: 3
Registered: October 2013
Junior Member
Hello,
I want to do the same thing
You can send me a sample source code complete with ". Rptdesign"

Or if you know a tutorial that explains how to do this it would be ideal if you transmettes us on the forum.

Big thank you in advance.
Previous Topic:How to override Page Autotext's initial value
Next Topic:Report execution in a swing application error :securityDomain should be null
Goto Forum:
  


Current Time: Tue Mar 19 09:33:27 GMT 2024

Powered by FUDForum. Page generated in 0.04981 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top