Testing the XML data extraction plug-in
You can run the new XML data extraction plug-in directly in BIRT Report Designer or programmatically when you run and render a report using the Web Viewer. This section describes how to test the XML data extraction plug‑in in BIRT Report Designer.
How to launch the XML data extraction plug-in
1 From the Eclipse SDK menu, choose Run—Run Configurations. In Run Configurations, right-click Eclipse Application. Choose New.
2 Create a configuration to launch an Eclipse application by performing the following tasks:
1 In Name, type:
XMLDataExtraction
2 On Main, in Location, type:
C:\Test\XMLDataExtraction
3 Run Configurations appears as shown in Figure 21‑9.
Figure 21‑9 Creating the XMLDataExtraction run configuration
4 Choose the Arguments tab and ensure that the following arguments are entered:
*Program arguments:
-os ${target.os} -ws ${target.ws} -arch ${target.arch}
-nl ${target.nl} -consoleLog
*VM arguments:
-Dosgi.requiredJavaVersion=1.6 -Xms40m -Xmx512m
-XX:MaxPermSize=256M
5 Choose the Plug-ins tab to select the list of plug-ins to launch with the run configuration.
6 In Launch with, choose:
plug-ins selected below only
from the drop-down list, as shown in Figure 21‑10.
Figure 21‑10 Selecting the XMLDataExtraction plug-in
7 Choose Run to launch the run-time Eclipse Workbench. A new instance of Eclipse opens up.
How to extract data from a BIRT report to XML format
BIRT Report Designer discovers the new XML data extraction plug-in and displays the new XML format in the Export Data menu.
1 In the new Eclipse Workbench, open the BIRT Report Design perspective.
2 In BIRT Report Designer perspective, open a BIRT report.
3 Choose RunView ReportIn Web Viewer from the main menu.
4 In the Web Viewer, select Export Data from the viewer toolbar, as shown in Figure 21‑11.
Figure 21‑11 Selecting the Export Data feature
5 In Export Data, choose the following options:
1 In Available Columns, press <CTRL> and select the columns to export.
2 Choose the arrow to move the columns to the Selected Columns list.
Use the double arrow to select and move all the columns in the data set.
Use the up and down arrows to change the order in which the columns appear in the output file.
3 In Export format, select XML(*.xml) from the list.
4 Select Export column’s data type and Export column as locale neutral, as shown in Figure 21‑12.
Figure 21‑12 Setting the export data properties
5 Choose OK to start the export.
6 Your browser may prompt you about how to handle the download. For example, Chrome shows a prompt at the bottom of the browser window, as shown in Figure 21‑13.
Figure 21‑13 Handling the exported XML data
7 Choose Keep or Save.
8 Open the saved XML file using any modern browser or XML editor. The structure of the file is similar to Listing 21‑1.
About the report design XML code
The XML file for the report design, new_report.rpdesign, contains the following source code settings, as specified in the report design:
*Data sources, including the ODA plug-in extension ID, driver class, URL, and user
*Data sets, including the ODA JDBC plug-in extension ID, result set properties, and query text
*Page setup, including the page footer
*Body, containing the table structure and properties for the bound data columns, including the header, footer, and detail rows
The report design example specifies a data source that connects to org.eclipse.birt.report.data.oda.sampledb, the BIRT Classic Models, Inc. sample database. Listing 21‑9 shows the XML source code for the report design used to test the XML data extraction example.
Listing 21‑9 The report design XML code
<?xml version="1.0" encoding="UTF-8"?>
<report xmlns="http://www.eclipse.org/birt/2005/design" version="3.2.23" id="1">
<property name="createdBy">Eclipse BIRT Designer Version 4.3.1.v201309091055 Build &lt;4.3.1.v20130917-1035></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.birt.report.data.oda.jdbc"name="Data Source" id="7">
<list-property name="privateDriverProperties">
<ex-property>
<name>contentBidiFormatStr</name>
<value>ILYNN</value>
</ex-property>
<ex-property>
<name>metadataBidiFormatStr</name>
<value>ILYNN</value>
</ex-property>
</list-property>
<property name="odaDriverClass">org.eclipse.birt.report.data.oda.sampledb.Driver</property>
<property name="odaURL">jdbc:classicmodels:sampledb</property>
<property name="odaUser">ClassicModels</property>
</oda-data-source>
</data-sources>
<data-sets>
<oda-data-set extensionID="org.eclipse.birt.report.data.oda.jdbc.JdbcSelectDataSet" name="Data Set" id="8">
<list-property name="columnHints">
<structure>
<property name="columnName">CUSTOMERNAME</property>
<text-property name="displayName">CUSTOMERNAME</text-property>
<text-property name="heading">CUSTOMERNAME</text-property>
</structure>
<structure>
<property name="columnName">CONTACTFIRSTNAME</property>
<text-property name="displayName">CONTACTFIRSTNAME</text-property>
<text-property name="heading">CONTACTFIRSTNAME</text-property>
</structure>
<structure>
<property name="columnName">PHONE</property>
<text-property name="displayName">PHONE</text-property>
<text-property name="heading">PHONE</text-property>
</structure>
</list-property>
<structure name="cachedMetaData">
<list-property name="resultSet">
<structure>
<property name="position">1</property>
<property name="name">CUSTOMERNAME</property>
<property name="dataType">string</property>
</structure>
<structure>
<property name="position">2</property>
<property name="name">CONTACTFIRSTNAME</property>
<property name="dataType">string</property>
</structure>
<structure>
<property name="position">3</property>
<property name="name">PHONE</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">CUSTOMERNAME</property>
<property name="nativeName">CUSTOMERNAME</property>
<property name="dataType">string</property>
<property name="nativeDataType">12</property>
</structure>
<structure>
<property name="position">2</property>
<property name="name">CONTACTFIRSTNAME</property>
<property name="nativeName">CONTACTFIRSTNAME</property>
<property name="dataType">string</property>
<property name="nativeDataType">12</property>
</structure>
<structure>
<property name="position">3</property>
<property name="name">PHONE</property>
<property name="nativeName">PHONE</property>
<property name="dataType">string</property>
<property name="nativeDataType">12</property>
</structure>
</list-property>
<xml-property name="queryText"><![CDATA[select CLASSICMODELS.CUSTOMERS.CUSTOMERNAME,CLASSICMODELS.CUSTOMERS.CONTACTFIRSTNAME,CLASSICMODELS.CUSTOMERS.PHONE
from CLASSICMODELS.CUSTOMERS]]></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>2.0</Version>
<design:ResultSets derivedMetaData="true">
<design:resultSetDefinitions>
<design:resultSetColumns>
<design:resultColumnDefinitions>
<design:attributes>
<design:identifier>
<design:name>CUSTOMERNAME</design:name>
<design:position>1</design:position>
</design:identifier>
<design:nativeDataTypeCode>12</design:nativeDataTypeCode>
<design:precision>50</design:precision>
<design:scale>0</design:scale>
<design:nullability>Nullable</design:nullability>
<design:uiHints>
<design:displayName>CUSTOMERNAME</design:displayName>
</design:uiHints>
</design:attributes>
<design:usageHints>
<design:label>CUSTOMERNAME</design:label>
<design:formattingHints>
<design:displaySize>50</design:displaySize>
</design:formattingHints>
</design:usageHints>
</design:resultColumnDefinitions>
<design:resultColumnDefinitions>
<design:attributes>
<design:identifier>
<design:name>CONTACTFIRSTNAME</design:name>
<design:position>2</design:position>
</design:identifier>
<design:nativeDataTypeCode>12</design:nativeDataTypeCode>
<design:precision>50</design:precision>
<design:scale>0</design:scale>
<design:nullability>Nullable</design:nullability>
<design:uiHints>
<design:displayName>CONTACTFIRSTNAME</design:displayName>
</design:uiHints>
</design:attributes>
<design:usageHints>
<design:label>CONTACTFIRSTNAME</design:label>
<design:formattingHints>
<design:displaySize>50</design:displaySize>
</design:formattingHints>
</design:usageHints>
</design:resultColumnDefinitions>
<design:resultColumnDefinitions>
<design:attributes>
<design:identifier>
<design:name>PHONE</design:name>
<design:position>3</design:position>
</design:identifier>
<design:nativeDataTypeCode>12</design:nativeDataTypeCode>
<design:precision>50</design:precision>
<design:scale>0</design:scale>
<design:nullability>Nullable</design:nullability>
<design:uiHints>
<design:displayName>PHONE</design:displayName>
</design:uiHints>
</design:attributes>
<design:usageHints>
<design:label>PHONE</design:label>
<design:formattingHints>
<design:displaySize>50</design:displaySize>
</design:formattingHints>
</design:usageHints>
</design:resultColumnDefinitions>
</design:resultSetColumns>
<design:criteria/>
</design:resultSetDefinitions>
</design:ResultSets>
</model:DesignValues>]]></xml-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">Data Set</property>
<list-property name="boundDataColumns">
<structure>
<property name="name">CUSTOMERNAME</property>
<text-property name="displayName">CUSTOMERNAME</text-property>
<expression name="expression" type="javascript">dataSetRow["CUSTOMERNAME"]</expression>
<property name="dataType">string</property>
</structure>
<structure>
<property name="name">CONTACTFIRSTNAME</property>
<text-property name="displayName">CONTACTFIRSTNAME</text-property>
<expression name="expression" type="javascript">dataSetRow["CONTACTFIRSTNAME"]</expression>
<property name="dataType">string</property>
</structure>
<structure>
<property name="name">PHONE</property>
<text-property name="displayName">PHONE</text-property>
<expression name="expression" type="javascript">dataSetRow["PHONE"]</expression>
<property name="dataType">string</property>
</structure>
</list-property>
<column id="28"/>
<column id="29"/>
<column id="30"/>
<header>
<row id="10">
<cell id="11">
<label id="12">
<text-property name="text">CUSTOMERNAME</text-property>
</label>
</cell>
<cell id="13">
<label id="14">
<text-property name="text">CONTACTFIRSTNAME</text-property>
</label>
</cell>
<cell id="15">
<label id="16">
<text-property name="text">PHONE</text-property>
</label>
</cell>
</row>
</header>
<detail>
<row id="17">
<cell id="18">
<data id="19">
<property name="resultSetColumn">CUSTOMERNAME</property>
</data>
</cell>
<cell id="20">
<data id="21">
<property name="resultSetColumn">CONTACTFIRSTNAME</property>
</data>
</cell>
<cell id="22">
<data id="23">
<property name="resultSetColumn">PHONE</property>
</data>
</cell>
</row>
</detail>
<footer>
<row id="24">
<cell id="25"/>
<cell id="26"/>
<cell id="27"/>
</row>
</footer>
</table>
</body>
</report>