Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » BIRT » Automatically generating a queryText for a xml dataset?
Automatically generating a queryText for a xml dataset? [message #556176] Tue, 31 August 2010 08:16 Go to next message
Eclipse UserFriend
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 15:30 Go to previous message
Jason Weathersby is currently offline Jason WeathersbyFriend
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 Mar 29 12:30:44 GMT 2024

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

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

Back to the top