Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » BIRT » Automatically generating a queryText for a xml dataset?
Automatically generating a queryText for a xml dataset? [message #556176] Tue, 31 August 2010 04:16 Go to next message
Eclipse User
Originally posted by: vm.vm.com

I am writing an application that creates a .rptdesign file from an xml
datasource and a dataset using the birt api. The datasource is an xml file
like the one below (the format cannot be changed):

<root>
<data id="document">
<section>
<subsection order="1.0" >
<variables>
<variable id="Name" value="name"/>
<variable id="Address" value="address"/>
</variables>
</subsection>
</section>
</data>
</root>


The resulting dataset should have the following queryString:

queryText =
table0#-TNAME-#table0#:#[/root/data/section/subsection/varia bles]#:#{name;STRING;/variable[@id= "Name"]/@value}

which corresponds to the value of the parameter where id=Name. The dataset
is then created using:

OdaDataSetHandle dataSetHandle =
elementFactory.newOdaDataSet(dataSetName,
"org.eclipse.birt.report.data.oda.xml.dataSet");
try {
dataSetHandle.setDataSource(dataSourceName);
dataSetHandle.setName(dataSetName);
} catch (SemanticException e) {
logger.error(
"Data source name: " + dataSourceName + " could not be set!", e);
}
....
....
dataSetHandle.setQueryText(queryText);





Currently I create the above queryString manually but is there some rutine
in the birt api for creating a OdaDataSetHandle based on a xml datasource
using either a querytext or something else in a more high-level way?
Re: Automatically generating a queryText for a xml dataset? [message #556291 is a reply to message #556176] Tue, 31 August 2010 11:30 Go to previous message
Jason Weathersby is currently offline Jason Weathersby
Messages: 9167
Registered: July 2009
Senior Member

I do not know of a public api to create the query string, but you can
checkout the xml oda from the datatools project and look at the
saveQueryString method of the ColumnMappingPage.java class to see how
the string is built.

Jason

On 8/31/2010 4:16 AM, vm wrote:
> I am writing an application that creates a .rptdesign file from an xml
> datasource and a dataset using the birt api. The datasource is an xml
> file like the one below (the format cannot be changed):
>
> <root>
> <data id="document">
> <section>
> <subsection order="1.0" >
> <variables>
> <variable id="Name" value="name"/>
> <variable id="Address" value="address"/>
> </variables>
> </subsection>
> </section>
> </data>
> </root>
>
>
> The resulting dataset should have the following queryString:
>
> queryText =
> table0#-TNAME-#table0#:#[/root/data/section/subsection/varia bles]#:#{name;STRING;/variable[@id= "Name"]/@value}
>
>
> which corresponds to the value of the parameter where id=Name. The
> dataset is then created using:
>
> OdaDataSetHandle dataSetHandle = elementFactory.newOdaDataSet(dataSetName,
> "org.eclipse.birt.report.data.oda.xml.dataSet");
> try {
> dataSetHandle.setDataSource(dataSourceName);
> dataSetHandle.setName(dataSetName);
> } catch (SemanticException e) {
> logger.error(
> "Data source name: " + dataSourceName + " could not be set!", e);
> }
> ....
> ....
> dataSetHandle.setQueryText(queryText);
>
>
>
>
>
> Currently I create the above queryString manually but is there some
> rutine in the birt api for creating a OdaDataSetHandle based on a xml
> datasource using either a querytext or something else in a more
> high-level way?
>
>
>
Previous Topic:Can't display Chart or Image in Excel export
Next Topic:AdapterException: The data source of this data set can not be null.
Goto Forum:
  


Current Time: Fri Aug 22 02:02:46 EDT 2014

Powered by FUDForum. Page generated in 0.03190 seconds