Set a XML DataSource Programmatically [message #346834] |
Tue, 29 January 2008 08:57  |
Eclipse User |
|
|
|
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   |
Eclipse User |
|
|
|
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 #360409 is a reply to message #360406] |
Tue, 29 January 2008 16:36   |
Eclipse User |
|
|
|
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   |
Eclipse User |
|
|
|
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   |
Eclipse User |
|
|
|
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?
>
>
>
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.02557 seconds