The nested tables with the XML source? [message #546748] |
Wed, 14 July 2010 05:56 |
Mika Tapanainen Messages: 55 Registered: July 2010 |
Member |
|
|
Hello,
How to design nested tables in the BIRT?
Here is my XML source:
<results>
<result>
<year value="2010"/>
<result value="100"/>
<details>
<detail>
<month value="Jan"/>
<points value="5"/>
</detail>
<detail>
<month value="Feb"/>
<points value="4"/>
</detail>
</details>
</result>
<result>
<year value="2009"/>
<result value="90"/>
<details>
<detail>
<month value="Jan"/>
<points value="8"/>
</detail>
<detail>
<month value="Feb"/>
<points value="9"/>
</detail>
<detail>
<month value="Mar"/>
<points value="15"/>
</detail>
</details>
</result>
</results>
and here is the table I want:
----------------
| 2010 | 100 |
----------------
| Jan | 5 | |
----------| |
| Feb | 4 | |
-----------------
| 2009 | 90 |
----------------
| Jan | 8 | |
----------| |
| Feb | 9 | |
----------| |
| Mar | 15| |
-----------------
How to design this with the BIRT? The contents of the table is dynamical, so for example there can be different number of the detail rows.
If you know how to solve this problem, it would be really great to receive the rptdesign file of the solution.
Thanks,
Mika
[Updated on: Wed, 14 July 2010 06:41] Report message to a moderator
|
|
|
Re: The nested tables with the XML source? [message #546896 is a reply to message #546748] |
Wed, 14 July 2010 14:05 |
|
I'm not an XML Data person, but the example you cite should be transformable to a set of rows:
Year, Result, Month, Points
Then you can take that dataset, put it into a table, and within the table create a group on Year to get a report like:
[Header row] Year, Value
[Detail row] Month, Points
...
[Detail row] Month, Points
[Header row] Year, Value
[Detail row] Month, Points
...
[Detail row] Month, Points
etcetera
|
|
|
Re: The nested tables with the XML source? [message #546966 is a reply to message #546896] |
Wed, 14 July 2010 18:24 |
|
I prefer Richard's approach, but if you want to use nested tables look
at the attached report that uses your data.
The inner table has a filter on it to filter on year. This could have
been done with a ds parameter but you would need to change your xml to
use a year attribute on the result element. I also had to change your
xml from
<result>
<year value="2009"/>
<result value="90"/>
to
<result>
<year value="2009"/>
<ttl value="90"/>
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 <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="8">
<text-property name="displayName"></text-property>
<property
name="FILELIST">C:\work\xmlreport\nestedxml\test.xml</property >
</oda-data-source>
</data-sources>
<data-sets>
<oda-data-set
extensionID="org.eclipse.datatools.enablement.oda.xml.dataSet "
name="outer" id="9">
<structure name="cachedMetaData">
<list-property name="resultSet">
<structure>
<property name="position">1</property>
<property name="name">Year</property>
<property name="dataType">string</property>
</structure>
<structure>
<property name="position">2</property>
<property name="name">Total</property>
<property name="dataType">decimal</property>
</structure>
</list-property>
</structure>
<property name="dataSource">Data Source</property>
<list-property name="resultSet">
<structure>
<property name="position">1</property>
<property name="name">Year</property>
<property name="nativeName">Year</property>
<property name="dataType">string</property>
<property name="nativeDataType">12</property>
</structure>
<structure>
<property name="position">2</property>
<property name="name">Total</property>
<property name="nativeName">Total</property>
<property name="dataType">decimal</property>
<property name="nativeDataType">2</property>
</structure>
</list-property>
<xml-property
name="queryText">< ![CDATA[table0#-TNAME-#table0#:#[/results/result]#:#{Year;ST RING;/year/@value},{Total;BIGDECIMAL;/ttl/@value}]] ></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>Year</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>Year</design:label>
<design:formattingHints/>
</design:usageHints>
</design:resultColumnDefinitions>
<design:resultColumnDefinitions>
<design:attributes>
<design:name>Total</design:name>
<design:position>2</design:position>
<design:nativeDataTypeCode>2</design:nativeDataTypeCode>
<design:precision>-1</design:precision>
<design:scale>-1</design:scale>
<design:nullability>Unknown</design:nullability>
</design:attributes>
<design:usageHints>
<design:label>Total</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="inner" id="29">
<structure name="cachedMetaData">
<list-property name="resultSet">
<structure>
<property name="position">1</property>
<property name="name">Month</property>
<property name="dataType">string</property>
</structure>
<structure>
<property name="position">2</property>
<property name="name">Points</property>
<property name="dataType">integer</property>
</structure>
<structure>
<property name="position">3</property>
<property name="name">Year</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">Month</property>
<property name="nativeName">Month</property>
<property name="dataType">string</property>
<property name="nativeDataType">12</property>
</structure>
<structure>
<property name="position">2</property>
<property name="name">Points</property>
<property name="nativeName">Points</property>
<property name="dataType">integer</property>
<property name="nativeDataType">4</property>
</structure>
<structure>
<property name="position">3</property>
<property name="name">Year</property>
<property name="nativeName">Year</property>
<property name="dataType">string</property>
<property name="nativeDataType">12</property>
</structure>
</list-property>
<xml-property
name="queryText">< ![CDATA[table0#-TNAME-#table0#:#[/results/result/details/det ail]#:#{Month;STRING;/month/@value},{Points;INT;/points/@val ue},{Year;STRING;../../year/@value}]] ></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>Month</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>Month</design:label>
<design:formattingHints/>
</design:usageHints>
</design:resultColumnDefinitions>
<design:resultColumnDefinitions>
<design:attributes>
<design:name>Points</design:name>
<design:position>2</design:position>
<design:nativeDataTypeCode>4</design:nativeDataTypeCode>
<design:precision>-1</design:precision>
<design:scale>-1</design:scale>
<design:nullability>Unknown</design:nullability>
</design:attributes>
<design:usageHints>
<design:label>Points</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="30">
<property name="dataSet">outer</property>
<list-property name="boundDataColumns">
<structure>
<property name="name">Year</property>
<text-property name="displayName">Year</text-property>
<expression name="expression"
type="javascript">dataSetRow["Year"]</expression>
<property name="dataType">string</property>
</structure>
<structure>
<property name="name">Total</property>
<text-property name="displayName">Total</text-property>
<expression name="expression"
type="javascript">dataSetRow["Total"]</expression>
<property name="dataType">decimal</property>
</structure>
</list-property>
<column id="44"/>
<column id="45"/>
<header>
<row id="31">
<cell id="32">
<label id="33">
<text-property name="text">Year</text-property>
</label>
</cell>
<cell id="34">
<label id="35">
<text-property
name="text">Total</text-property>
</label>
</cell>
</row>
</header>
<detail>
<row id="36">
<cell id="37">
<data id="38">
<property
name="resultSetColumn">Year</property>
</data>
</cell>
<cell id="39">
<data id="40">
<property
name="resultSetColumn">Total</property>
</data>
</cell>
</row>
<row id="46">
<cell id="47">
<table id="65">
<property name="dataSet">inner</property>
<list-property name="boundDataColumns">
<structure>
<property name="name">Month</property>
<text-property
name="displayName">Month</text-property>
<expression name="expression"
type="javascript">dataSetRow["Month"]</expression>
<property
name="dataType">string</property>
</structure>
<structure>
<property name="name">Points</property>
<text-property
name="displayName">Points</text-property>
<expression name="expression"
type="javascript">dataSetRow["Points"]</expression>
<property
name="dataType">integer</property>
</structure>
<structure>
<property name="name">Year</property>
<text-property
name="displayName">Year</text-property>
<expression name="expression"
type="javascript">dataSetRow["Year"]</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["Year"]</expression>
<simple-property-list name="value1">
<value>row._outer["Year"]</value>
</simple-property-list>
</structure>
</list-property>
<column id="84"/>
<column id="85"/>
<detail>
<row id="73">
<cell id="74">
<data id="75">
<property
name="resultSetColumn">Month</property>
</data>
</cell>
<cell id="76">
<data id="77">
<property
name="resultSetColumn">Points</property>
</data>
</cell>
</row>
</detail>
</table>
</cell>
<cell id="48"/>
</row>
</detail>
<footer>
<row id="41">
<cell id="42"/>
<cell id="43"/>
</row>
</footer>
</table>
</body>
</report>
On 7/14/2010 10:06 AM, Richard A. Polunsky wrote:
> I'm not an XML Data person, but the example you cite should be
> transformable to a set of rows:
>
> Year, Result, Month, Points
>
> Then you can take that dataset, put it into a table, and within the
> table create a group on Year to get a report like:
>
> [Header row] Year, Value
> [Detail row] Month, Points
> ...
> [Detail row] Month, Points
>
> [Header row] Year, Value
> [Detail row] Month, Points
> ...
> [Detail row] Month, Points
>
> etcetera
>
|
|
|
Powered by
FUDForum. Page generated in 0.02058 seconds