Automatically generating a queryText for a xml dataset? [message #556176] |
Tue, 31 August 2010 08:16 |
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 15:30 |
|
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?
>
>
>
|
|
|
Powered by
FUDForum. Page generated in 0.02713 seconds