BIRT Exchange Forum: Flexible BIRT reports and dynamic images from URLs - BIRT Exchange Forum

Jump to content


 

BIRT Poll: To best make a table fill a pdf page before breaking (PL=page layout, PBI=page break interval) set:

PL: auto, PBI: 0PL: fixed, PBI: 0PL: auto, PBI: 1000000PL: fixed, PBI: 1000000
Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Flexible BIRT reports and dynamic images from URLs Rate Topic: -----

#1 User is offline   locutuz Icon

  • Member
  • PipPip
  • Group: Members
  • Posts: 24
  • Joined: 25-October 11


Posted 25 October 2011 - 03:39 AM

Hello everybody,

I am new to BIRT but I'd like to have BIRT as the report-engine in my application.
My post is a little big but that's the only way I can describe my "problems".
First I try to describe my environment and my approches. At the end I have problem
descriptions for them I couldn't find any answers on the net.

The data for the report comes from an XML file that is generated by the main application.
This data file serves as input for the report generator. The result of the report generator
is a HTML file based on the data within the XML file and a report design.

My system consists of 3 separate applications:
1.) The main application
2.) The report generator (BIRT console program, e.g. ReportGen.exe)
3.) The report designer (BIRT Standalone)

The layout of the system would be preferable as pictured as followed.

-> Location of the main application and the report generator application:
D:\Program Files\MainApplication\Reporting\Designs\*.rptdesign
\Data\alldata.xml
\Output\<result.html>
RepGen.exe (is located in the "Reporting"-main folder)



-> Location of the BIRT Designer:
D:\Program Files\BIRT-ReportDesigner

As a data source I have a XML file that's located in D:\Program Files\MainApplication\Reporting\Data\data.xml.
It looks like:
<Root>
<Elements>
<Element Name="First element" ImageUrl=".\images\img_el01.jpg" />
<Element Name="Second element" ImageUrl=".\images\img_el02.jpg" />
</Elements>
</Root>

The report generator application is a simple console application that takes 3 program parameters:
1 - Path to the data.xml file (D:\Program Files\MainApplication\Reporting\Data\data.xml)
2 - Path to the report design file (D:\Program Files\MainApplication\Reporting\Designs\simple_report.rptdesign)
3 - Path and name of the outputfile (D:\Program Files\MainApplication\Reporting\Output\output_simple_report.html)

Process description:
--------------------
- BIRT Report Designer
The report design is created independently of the actual XML data file, i.e. I create a report design today on basis
of a sample XML file that represents the correct structure of the actual data files. The report design is stored under the
"Designs"-subdirectory of the main application. E.g.: D:\Program Files\MainApplication\Reporting\Designs\rep_example.rptdesign.
The report design (and the sample data file and schema file) are part of the product delivery of the main application.
(So the installation path of the main application and report generator may be unknown when a report is designed. This prohibits
the use of absolute file-/directory-paths.)

- Main application (Runtime)
In the main application I trigger the reporting functionality and select the report to be generated that bases on e.g. the rep_example.rptdesign.
The application collects all the information needed and create a valid data file according the xsd file. The data file is stored in the
"Data"-subdirectory of the main application. E.g.: D:\Program Files\MainApplication\Reporting\Data\data_example.xml.
- Report generator
The report generator is called automatically by the main application when the generation of the data XMl was finished. The main application
calls the report generator and pass for the parameters the two files created above and an output file. E.g.:

ReportGen.exe .\Data\data_example.xml .\Designs\simple_report.rptdesign .\Output\result.html


Note: The paths in this example shall be exchangable, the goal is to have no static, absolute paths and filenames within the reportdesign.

----------------------------------------------
Problem 1: Changing the data souce on runtime
----------------------------------------------
Is it possible to separate the XML data source from the report design?
When I look into the .rptdesign (XML view) that is connected to a xml data source, this data source appears hardcoded within the XML file:
...
<data-sources>
<oda-data-source extensionID="org.eclipse.datatools.enablement.oda.xml" name="001 Example DS" id="7">
<property name="FILELIST">D:\Temp\001_Example.xml</property>
</oda-data-source>
</data-sources>
...

Is it possible to "replace" the data source "001_Example.xml" file and location during runtime? If so how can I do this?
The new XML file and the 001_Exxample.xml have both to be valid to the same XSD-file.


------------------------------------------------------------
Problem 2: Dynamic image - Each element has its own graphic
------------------------------------------------------------
As you can see in the title of this problem I want to display a graphic for each element on the report. The graphic itself is generated when
the data XML file is generated as JPG file. My approach would be to store these JPGs in a relative folder to the data-folder (so the value of
the XML-attribute "ImageUrl" could be specified as a relative path). E.g.:
<Reporting>\Data\Images\Img_el01.jpg
The renderer now iterates over the data XML and (e.g.) fill a table with 2 columns (name, graphic) on the report. The "name"-column will display
the name of the element as specified in the "Name"-XML-attribute (e.g.: "First element", "Second element", ...). Within the "Graphic"-column the
associated image shall be displayed (img_el01.jpg, img_el02.jpg, ...).
Here it would be the best when the imiages are referenced within the resulting HTML-file. E.g. I'd like to have the following HTML-output for the
two described example elements:
...
<table ...>
<tr...>
<th ..>Name</th>
<th ..>Graphic</th>
</tr>
<tr ...>
<td ..>First element</td>
<td ..><img src=".\images\img_el01.jpg" /></td>
</tr>
<tr ...>
<td ..>Second element</td>
<td ..><img src=".\images\img_el02.jpg" /></td>
</tr>
...
</table>

The images are copied into a "images"-subfolder relative to the output-folder to garantee the reachability of the image reference.

Unfortunately I couldn't find an example or other hints to support me in my deeds. That's why I turned to this forum with the hope to get an answer or
(even better) a proposal for solution for my problems.

Any help is welcome since I am pretty new to the BIRT-stuff.


Thanks in advance.


Regards,
Sebastian
0

#2 User is offline   mwilliams Icon

  • BIRT Guru
  • Icon
  • View blog
  • Group: Administrators
  • Posts: 12945
  • Joined: 16-May 08


Posted 02 December 2011 - 05:33 AM

Sorry for the delayed response. Design questions are best asked in the designing birt reports forum where there is more traffic. Did you find a solution to your issue?
Regards,

Michael

Twitter
Facebook
Blog
Yahoo: mwilliams_actuate@yahoo.com
Google: mwilliams.actuate@gmail.com
0

#3 User is offline   locutuz Icon

  • Member
  • PipPip
  • Group: Members
  • Posts: 24
  • Joined: 25-October 11


Posted 09 December 2011 - 01:55 AM

View Postmwilliams, on 02 December 2011 - 06:33 AM, said:

Sorry for the delayed response. Design questions are best asked in the designing birt reports forum where there is more traffic. Did you find a solution to your issue?


Thanks for the reply, and sorry for the "wrong" forum.
To answer your question: I solved half of my issues, the one changing the (XML) data source at run-time. Below there is my solution. The other issue I didn't solve 'til now, but if I have a solution, I also will post it here.

Regards,
Sebastian

----------------------------------------------
Problem 1: Changing the data souce on runtime
----------------------------------------------

This problem I solved like described below:
For the report design I added a report parameter "XMLDataSource".
1. Select the report design file and swtich to the "Data"-tab.
2. Add a report parameter named "XMLDataSource".
3. Open the required Datasource (XML-DataSource) and select the "Property Binding" entry.
4. Enter in the edit box named "XML Data Source File" the following value:
params["XMLDataSource"].value
This can also be done with the Javascript expression editor.

=>
Now when I open the report-preview, a message box appears asking me for the report parameter.
Here enter the path and file of the XML-Data file.
In my environment I pass the parameter to the RepGen application to avoid the text box appearing.
0

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users