Converting Oracle Reports (.rdf) to BIRT reports
I have som开发者_如何学编程e Oracle Reports (.rdf) that I am considering converting to BIRT reports. Is there a way to convert .rdf files to BIRT report design files?
A fully automated solution is probably not possible. You can partially automate the conversion process as follows:
- Convert the RDF files to XML.
- Extract the report query.
- Convert the XML to BIRT (or JRXML) using XSLT.
XML Conversion
The first step is fairly simple, using Cygwin:
cd /path/to/reports/
mkdir xml
for i in *.rdf; do
rwconverter.exe batch=yes source="$i" dest=xml/"$i".xml dtype=xmlfile \
userid=scott/tiger@xe
done
Extraction
The second step is also relatively easy, using starlet (rename xml.exe
to starlet.exe
to avoid conflicts with Oracle's xml.exe
):
starlet.exe sel -t -v "/report/data/dataSource/select" filename.rdf.xml
You can also use xmllint, but it includes the select
and CDATA
elements, which you'd have to parse separately:
xmllint --xpath /report/data/dataSource/select filename.rdf.xml
Format Conversion
The third step is challenging. Create an XSL template that reads the RDF layouts (e.g., <displayInfo x="0.74377" y="0.97913" width="1.29626" height="1.62695" />
). Then convert those layouts to the corresponding format used by the destination report engine (such as BIRT or JasperReports).
You wouldn't get a 100% solution, but an 80% solution could significantly reduce the amount of monotonous, error-prone work required to convert the reports.
I once had a job to convert *.rdf files to Jasper reports. Since I don't know BIRT, I have no idea if this approach would work with BIRT, too.
Anyway, I exported the *.rdf files as xml and parsed the output with Perl and wrote the Jasper definitions, also as xml. For most reports, this worked pretty well. I have -however- one report in mind that I couldn't translate automatically: that was a report where the result set of two queries were laid out side by side.
I haven't found any tools which do this. Some might call this a business opportunity.
RDF
files, as far as I can tell, are in some funky binary format. To even have a shot at this, I'd probably convert it first into a REX
file, which is supposed to be portable xml. Then, it is a matter of transforming from the REX
structure to the BIRT
structure. Honestly, I have no idea how documented the REX file is, but maybe since you know how it looks from the visual side you can make sense of it.
Good luck!
精彩评论