Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » BIRT » Subreport with XML data source
Subreport with XML data source [message #631305] Wed, 06 October 2010 22:36 Go to next message
Bea  is currently offline Bea Friend
Messages: 3
Registered: October 2010
Junior Member
Hi all,

I'm trying to generate a subreport inside a report with XML as data source. I have problems because I don't know how to get it.
Could anyone tell me how to do this? I don't see any documentation about subreports with XML as data source, and I'm quite newbie with eclilpse BIRT.

Thanks for your help,
Best regards
Re: Subreport with XML data source [message #631453 is a reply to message #631305] Thu, 07 October 2010 14:54 Go to previous messageGo to next message
Jason Weathersby is currently offline Jason WeathersbyFriend
Messages: 9167
Registered: July 2009
Senior Member

Does the sub report use the same xml as the master? Can you give some
more detail on what you need? For example do you have an outer dataset
that list ids and you want these ids passed to the subreports so they
only get xml for those ids.

Jason

On 10/6/2010 6:36 PM, Bea wrote:
> Hi all,
>
> I'm trying to generate a subreport inside a report with XML as data
> source. I have problems because I don't know how to get it. Could anyone
> tell me how to do this? I don't see any documentation about subreports
> with XML as data source, and I'm quite newbie with eclilpse BIRT.
>
> Thanks for your help,
> Best regards
Re: Subreport with XML data source [message #631479 is a reply to message #631453] Thu, 07 October 2010 16:17 Go to previous messageGo to next message
Bea  is currently offline Bea Friend
Messages: 3
Registered: October 2010
Junior Member
Hi,

I should have explained better. The xml is the same for the master and detail, although I have different data sets for each one. My expected result should be the following:

document
--services
----concepts

Each element has an id. What I want is to embed a table of concepts into its corresponding service (services is another table). Say that a service is the master and a concept the detail. I'd like to know what is the best way to link the concepts subreport to the service report, as with a JDBC data source is easy to create a query with a parameter in the where clause and then pass the parameter in the subreport, but with the xml as data source I can't accomplish it.

This is a summarized version of my XML:

<document>
	<id>1</id>
	<name>main document</name>
	<services>
            <service>
                <id>S1</id>
                <concepts>
                    <concept>
                        <id>30</id>
  			<name>Concept 1</name>
                    </concept>
                </concepts>
            </service>
            <service>
                <id>2</id>        
                <concepts>
                    <concept>
	                <id>47</id>
                        <name>Concept 2</name>              
                    </concept>
                </concepts>
            </service>
      </services>
</document>


Thanks for your help,
Bea.
Re: Subreport with XML data source [message #631498 is a reply to message #631479] Thu, 07 October 2010 17:45 Go to previous messageGo to next message
Jason Weathersby is currently offline Jason WeathersbyFriend
Messages: 9167
Registered: July 2009
Senior Member

If your xml was slightly different you could use the xml data source
parameter feature described here:
http://www.eclipse.org/birt/phoenix/project/notable2.5.php#j ump_10
It would require that your service id be an attribute not a node. If
you cant change it the best way to do this is to add the master table
for services and then create a dataset that retrieves all the concepts.
drag this dataset to a nested table. Add a filter to the table that
filters on the outer table's service id. I took your example xml and
pasted it to an xml file an wrote a small report off of it. Just change
the datasource xml file location and it should run.

Jason

<?xml version="1.0" encoding="UTF-8"?>
<report xmlns="http://www.eclipse.org/birt/2005/design" version="3.2.21"
id="1">
<property name="createdBy">Eclipse BIRT Designer Version
2.5.2.v20100208 Build &lt;2.5.2.v20100210-0630></property>
<property name="units">in</property>
<property name="iconFile">/templates/blank_report.gif</property>
<property name="bidiLayoutOrientation">ltr</property>
<property name="imageDPI">96</property>
<data-sources>
<oda-data-source
extensionID="org.eclipse.datatools.enablement.oda.xml" name="Data
Source" id="7">
<text-property name="displayName"></text-property>
<property
name="FILELIST">C:\work\examplereports\xmldatasource.xml</property >
</oda-data-source>
</data-sources>
<data-sets>
<oda-data-set
extensionID="org.eclipse.datatools.enablement.oda.xml.dataSet "
name="Services" id="8">
<structure name="cachedMetaData">
<list-property name="resultSet">
<structure>
<property name="position">1</property>
<property name="name">id</property>
<property name="dataType">string</property>
</structure>
</list-property>
</structure>
<property name="dataSource">Data Source</property>
<list-property name="resultSet">
<structure>
<property name="position">1</property>
<property name="name">id</property>
<property name="nativeName">id</property>
<property name="dataType">string</property>
<property name="nativeDataType">12</property>
</structure>
</list-property>
<xml-property
name="queryText">< ![CDATA[table0#-TNAME-#table0#:#[/document/services/service] #:#{id;STRING;/id}]] ></xml-property>
<xml-property name="designerValues"><![CDATA[<?xml
version="1.0" encoding="UTF-8"?>
<model:DesignValues
xmlns:design="http://www.eclipse.org/datatools/connectivity/oda/design"
xmlns:model="http://www.eclipse.org/birt/report/model/adapter/odaModel">
<Version>1.0</Version>
<design:ResultSets derivedMetaData="true">
<design:resultSetDefinitions>
<design:resultSetColumns>
<design:resultColumnDefinitions>
<design:attributes>
<design:name>id</design:name>
<design:position>1</design:position>
<design:nativeDataTypeCode>12</design:nativeDataTypeCode>
<design:precision>-1</design:precision>
<design:scale>-1</design:scale>
<design:nullability>Unknown</design:nullability>
</design:attributes>
<design:usageHints>
<design:label>id</design:label>
<design:formattingHints/>
</design:usageHints>
</design:resultColumnDefinitions>
</design:resultSetColumns>
<design:criteria/>
</design:resultSetDefinitions>
</design:ResultSets>
</model:DesignValues>]]></xml-property>
<list-property name="privateDriverProperties">
<ex-property>
<name>MAX_ROW</name>
<value>-1</value>
</ex-property>
<ex-property>
<name>XML_FILE</name>
</ex-property>
</list-property>
</oda-data-set>
<oda-data-set
extensionID="org.eclipse.datatools.enablement.oda.xml.dataSet "
name="Concepts" id="19">
<structure name="cachedMetaData">
<list-property name="resultSet">
<structure>
<property name="position">1</property>
<property name="name">id</property>
<property name="dataType">string</property>
</structure>
<structure>
<property name="position">2</property>
<property name="name">name</property>
<property name="dataType">string</property>
</structure>
<structure>
<property name="position">3</property>
<property name="name">serviceid</property>
<property name="dataType">string</property>
</structure>
</list-property>
</structure>
<property name="dataSource">Data Source</property>
<list-property name="resultSet">
<structure>
<property name="position">1</property>
<property name="name">id</property>
<property name="nativeName">id</property>
<property name="dataType">string</property>
<property name="nativeDataType">12</property>
</structure>
<structure>
<property name="position">2</property>
<property name="name">name</property>
<property name="nativeName">name</property>
<property name="dataType">string</property>
<property name="nativeDataType">12</property>
</structure>
<structure>
<property name="position">3</property>
<property name="name">serviceid</property>
<property name="nativeName">serviceid</property>
<property name="dataType">string</property>
<property name="nativeDataType">12</property>
</structure>
</list-property>
<xml-property
name="queryText">< ![CDATA[table0#-TNAME-#table0#:#[/document/services/service/ concepts/concept]#:#{id;STRING;/id},{name;STRING;/name},{ser viceid;STRING;../../id}]] ></xml-property>
<xml-property name="designerValues"><![CDATA[<?xml
version="1.0" encoding="UTF-8"?>
<model:DesignValues
xmlns:design="http://www.eclipse.org/datatools/connectivity/oda/design"
xmlns:model="http://www.eclipse.org/birt/report/model/adapter/odaModel">
<Version>1.0</Version>
<design:ResultSets derivedMetaData="true">
<design:resultSetDefinitions>
<design:resultSetColumns>
<design:resultColumnDefinitions>
<design:attributes>
<design:name>id</design:name>
<design:position>1</design:position>
<design:nativeDataTypeCode>12</design:nativeDataTypeCode>
<design:precision>-1</design:precision>
<design:scale>-1</design:scale>
<design:nullability>Unknown</design:nullability>
</design:attributes>
<design:usageHints>
<design:label>id</design:label>
<design:formattingHints/>
</design:usageHints>
</design:resultColumnDefinitions>
<design:resultColumnDefinitions>
<design:attributes>
<design:name>name</design:name>
<design:position>2</design:position>
<design:nativeDataTypeCode>12</design:nativeDataTypeCode>
<design:precision>-1</design:precision>
<design:scale>-1</design:scale>
<design:nullability>Unknown</design:nullability>
</design:attributes>
<design:usageHints>
<design:label>name</design:label>
<design:formattingHints/>
</design:usageHints>
</design:resultColumnDefinitions>
</design:resultSetColumns>
<design:criteria/>
</design:resultSetDefinitions>
</design:ResultSets>
</model:DesignValues>]]></xml-property>
<list-property name="privateDriverProperties">
<ex-property>
<name>MAX_ROW</name>
<value>-1</value>
</ex-property>
<ex-property>
<name>XML_FILE</name>
</ex-property>
</list-property>
</oda-data-set>
</data-sets>
<styles>
<style name="report" id="4">
<property name="fontFamily">sans-serif</property>
<property name="fontSize">10pt</property>
</style>
<style name="crosstab-cell" id="5">
<property name="borderBottomColor">#CCCCCC</property>
<property name="borderBottomStyle">solid</property>
<property name="borderBottomWidth">1pt</property>
<property name="borderLeftColor">#CCCCCC</property>
<property name="borderLeftStyle">solid</property>
<property name="borderLeftWidth">1pt</property>
<property name="borderRightColor">#CCCCCC</property>
<property name="borderRightStyle">solid</property>
<property name="borderRightWidth">1pt</property>
<property name="borderTopColor">#CCCCCC</property>
<property name="borderTopStyle">solid</property>
<property name="borderTopWidth">1pt</property>
</style>
<style name="crosstab" id="6">
<property name="borderBottomColor">#CCCCCC</property>
<property name="borderBottomStyle">solid</property>
<property name="borderBottomWidth">1pt</property>
<property name="borderLeftColor">#CCCCCC</property>
<property name="borderLeftStyle">solid</property>
<property name="borderLeftWidth">1pt</property>
<property name="borderRightColor">#CCCCCC</property>
<property name="borderRightStyle">solid</property>
<property name="borderRightWidth">1pt</property>
<property name="borderTopColor">#CCCCCC</property>
<property name="borderTopStyle">solid</property>
<property name="borderTopWidth">1pt</property>
</style>
</styles>
<page-setup>
<simple-master-page name="Simple MasterPage" id="2">
<page-footer>
<text id="3">
<property name="contentType">html</property>
<text-property
name="content"><![CDATA[<value-of>new Date()</value-of>]]></text-property>
</text>
</page-footer>
</simple-master-page>
</page-setup>
<body>
<table id="9">
<property name="dataSet">Services</property>
<list-property name="boundDataColumns">
<structure>
<property name="name">id</property>
<text-property name="displayName">id</text-property>
<expression name="expression"
type="javascript">dataSetRow["id"]</expression>
<property name="dataType">string</property>
</structure>
</list-property>
<column id="18"/>
<column id="23"/>
<header>
<row id="10">
<cell id="11">
<label id="12">
<text-property name="text">id</text-property>
</label>
</cell>
<cell id="20"/>
</row>
</header>
<detail>
<row id="13">
<cell id="14">
<data id="15">
<property name="resultSetColumn">id</property>
</data>
</cell>
<cell id="21">
<table id="24">
<property name="dataSet">Concepts</property>
<list-property name="boundDataColumns">
<structure>
<property name="name">id</property>
<text-property
name="displayName">id</text-property>
<expression name="expression"
type="javascript">dataSetRow["id"]</expression>
<property
name="dataType">string</property>
</structure>
<structure>
<property name="name">name</property>
<text-property
name="displayName">name</text-property>
<expression name="expression"
type="javascript">dataSetRow["name"]</expression>
<property
name="dataType">string</property>
</structure>
<structure>
<property
name="name">serviceid</property>
<text-property
name="displayName">serviceid</text-property>
<expression name="expression"
type="javascript">dataSetRow["serviceid"]</expression>
<property
name="dataType">string</property>
</structure>
</list-property>
<list-property name="filter">
<structure>
<property name="operator">eq</property>
<expression name="expr"
type="javascript">row["serviceid"]</expression>
<simple-property-list name="value1">
<value>row._outer["id"]</value>
</simple-property-list>
</structure>
</list-property>
<column id="43"/>
<column id="44"/>
<column id="45"/>
<header>
<row id="25">
<cell id="26">
<label id="27">
<text-property
name="text">id</text-property>
</label>
</cell>
<cell id="28">
<label id="29">
<text-property
name="text">name</text-property>
</label>
</cell>
<cell id="30">
<label id="31">
<text-property
name="text">serviceid</text-property>
</label>
</cell>
</row>
</header>
<detail>
<row id="32">
<cell id="33">
<data id="34">
<property
name="resultSetColumn">id</property>
</data>
</cell>
<cell id="35">
<data id="36">
<property
name="resultSetColumn">name</property>
</data>
</cell>
<cell id="37">
<data id="38">
<property
name="resultSetColumn">serviceid</property>
</data>
</cell>
</row>
</detail>
<footer>
<row id="39">
<cell id="40"/>
<cell id="41"/>
<cell id="42"/>
</row>
</footer>
</table>
</cell>
</row>
</detail>
<footer>
<row id="16">
<cell id="17"/>
<cell id="22"/>
</row>
</footer>
</table>
</body>
</report>


On 10/7/2010 12:17 PM, Bea wrote:
> <document>
> <id>1</id>
> <name>main document</name>
> <services>
> <service>
> <id>S1</id>
> <concepts>
> <concept>
> <id>30</id>
> <name>Concept 1</name>
> </concept>
> </concepts>
> </service>
> <service>
> <id>2</id> <concepts>
> <concept>
> <id>47</id>
> <name>Concept 2</name> </concept>
> </concepts>
> </service>
> </services>
> </document>
Re: Subreport with XML data source [message #631618 is a reply to message #631498] Fri, 08 October 2010 08:26 Go to previous message
Bea  is currently offline Bea Friend
Messages: 3
Registered: October 2010
Junior Member
Now it works. I didn't realized that I can filter in the table by an outer id. Easy and simple.

Thanks!!

Bea.
Previous Topic:Using RE API without birt installed on the server machine
Next Topic:Comparing 2 BIRT report
Goto Forum:
  


Current Time: Fri Apr 26 11:08:48 GMT 2024

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

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

Back to the top