将 Oracle 报告 (.rdf) 转换为 BIRT 报告
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/4695465/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Converting Oracle Reports (.rdf) to BIRT reports
提问by shikarishambu
I have some Oracle Reports (.rdf) that I am considering converting to BIRT reports. Is there a way to convert .rdf files to BIRT report design files?
我有一些 Oracle 报告 (.rdf),我正在考虑将其转换为 BIRT 报告。有没有办法将 .rdf 文件转换为 BIRT 报告设计文件?
回答by Dave Jarvis
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.
- 将 RDF 文件转换为 XML。
- 提取报告查询。
- 使用 XSLT 将 XML 转换为 BIRT(或 JRXML)。
XML Conversion
XML 转换
The first step is fairly simple, using Cygwin:
第一步相当简单,使用 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
):
第二个步骤是也比较容易,使用新星(重命名xml.exe
以starlet.exe
与Oracle的避免冲突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,但它包括select
和CDATA
元素,您必须单独解析它们:
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).
第三步是具有挑战性的。创建读取 RDF 布局(例如,<displayInfo x="0.74377" y="0.97913" width="1.29626" height="1.62695" />
)的 XSL 模板。然后将这些布局转换为目标报表引擎(例如 BIRT 或 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.
您不会得到 100% 的解决方案,但 80% 的解决方案可以显着减少转换报告所需的单调、容易出错的工作量。
回答by René Nyffenegger
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.
我曾经有一份工作将 *.rdf 文件转换为 Jasper 报告。因为我不知道 BIRT,所以我不知道这种方法是否也适用于 BIRT。
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 twoqueries were laid out side by side.
无论如何,我将 *.rdf 文件导出为 xml 并使用 Perl 解析输出并编写 Jasper 定义,也作为 xml。对于大多数报告,这工作得很好。但是,我有一个报告,我无法自动翻译:这是一份报告,其中两个查询的结果集并排布置。
回答by Adam Hawkes
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 portablexml. 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.
RDF
文件,据我所知,是一些时髦的二进制格式。为了对此有所了解,我可能会先将其转换为一个REX
文件,该文件应该是可移植的xml。那么,就是从REX
结构到BIRT
结构的转变。老实说,我不知道 REX 文件是如何记录的,但也许因为您知道它从视觉方面的外观,您可以理解它。
Good luck!
祝你好运!