LRpt::XMLReport is a part of LRpt (LReport) library.
It used to convert outputs generated by other tools from LReport suite to
XML format. You should not call this class directly from your code.
Instead you should use lrptxml.pl tool, which is a simple wrapper around
this module. It looks like this:
use strict;
use LRpt::XMLReport;
create_report( @ARGV );
Optional. Name of a selects file (see doc). They are included in the
report for a select of corresponding name. If selects are not given, report
will not contain selects.
We will continue using an example from manual page for LRpt.
Our goal would be to generate
an RTF document, which looks like the one given at http:/xxxx.
As you remember, we finished with the output of lcsvdiff.pm
We will create an XML document and then we will process it with
XSLT processor to get a final RTF document.
One of possible inputs for lrptxml.pm is output generated by
lcsvdiff.pm. However, this is not exactly the format generated in the
example shown in LRpt manual page. The format used there, contained
only information about changes. In order to generate a full report we will
have to use --all switch when calling lcsvdiff.pm. This switch
will generate the following output:
lcsvdiff.pl before/customer.txt after/customer.txt
SCHEMA: customer_id name last_name address
ROW( 1234 ): 1234 Jan Nowak Warszawa
lcsvdiff.pl before/service.txt after/service.txt
SCHEMA: customer_id service_type price status
INS( 1234#GPRS ): 1234 GPRS 2.05 ACTIVE
DEL( 1234#MAIL ): 1234 MAIL 1.30 ACTIVE
ROW( 1234#VOICE ): 1234 VOICE 0.34 DEACTIVATED
UPD( 1234#VOICE ): status: ACTIVE =#=> DEACTIVATED
As you can see, differences are reported together with information about
all rows returned by selects.
A file containing selects. This is the same file as used by lcsvdmp.pl.
It is used here to include in XML report the full text of select, which
returned presented rows
File with a definiton of row keys. This is exactly the same type of file
as used by lcsvdiff.pl tool. It is used here to order rows in the report
properly.
The report tag is a root element. Each of its children is a select.
The example above has 2 selects: customer and service.
Each select element has 3 children:
The row is present in the after and before collection. There are some
differences found in columns' values.
You can read about XML report format in more details later in xxx.
Now you can get XSLT stylesheets for RTF from source forge and process
the generated report. There is some fuzziness around XSLT specification so
I can't guarantee that it will work for any XSLT processor. But it worked
for me with Saxon.
After getting RTF stylesheet and installing Saxon, you can run the
conversion. On my Windows machine it look like this:
In csv mode (default one)
lrptxmp.pl will pick all
files with expected extension found is this directory. Since there would
be no comparison information, all rows will be reported as equal.
Second mode is diffs mode, when lrptxml.pl accepts on input a file
produced by lcsvdiff.pl tool ran with --all switch.
In this mode differences are reflected in the output report.
In order to switch to diffs mode, --diffs switch has to be used.
XML report has to be well formed. Its root element is report.
Its direct children are elements dedicated to results of single selects.
Name of each of this elements is a name of a select.
The general structure of an XML report is given below:
Contains actual rows. It may have 4 types of child elements:
equal
No differences reported for a given row. Child elements are columns, their
value are values from columns.
different
Row existed in after and before collections. Values in some
columns were different. Child elements are columns, their values are values
from columns for all columns except columns where differences were found.
For those columns, column element contains to child elements: old_value and
new_value which contains values from before and after rows.
additional
before row does not exist, after row does.
Child elements are columns, their
value are values from columns.
missing
before row exists, after row doesn't.
Child elements are columns, their
values are values from columns.
RTF converter create an RTF document. An example of such a document
can be found at xxx.
Section containing results of one
select consists of select statement text and then rows. Rows are not
presented in the tables. Instead each row is one paragraph, with fields
separated by tabs. This is good for presenting multi row selects.
Using tables would make columns very narrow and hardly readable.
Header, containg all columns to be reported is
printed in bold on a gray background. Every second row is shaded, so it's
easier to see which values belongs to which row.
Additional rows (see before-after comparison) are printed using italics, bold
and double underline.
Missing rows are (see before-after comparison) are printed using stroke through
Different rows (see before-after comparison) are presented in standard font.
Only columns that differ are printed in bold, italics and underline.
We can choose to highlight some columns with some colors. It is helpful when
viewing reports with many columns. Highlighting can be used to point readers
attention to most important data.
To be edited by you. Contains details of formating in RTF documents.
rldf stands for Report Layout Definition File.
An example of rldf is given below:
It contains some standard stuff related to XSLT. The only part, which should
be modified by you is contents of rld variable element. You can read
details on rld in next chapter.
rld is an XML tree, used to specify details on how are select results
shown in RTF document. It allows to specify, which columns should be on
the report and with what color it should be highlighted.
Element named as a select name defines details for a given select. This element
has one attribute: all. If this attributes value is 1 than all columns
from the select are shown in RTF document.
Each select element has children elements for columns. Column element may
have one attribute, color, which defines color of column's highlighting.
Possible values are xxxx.
If all attribute is not set to 1 then only those columns are present
in RTF document, for which column elements are present in rld.
If all attribute is set to 1 then all columns are present
in RTF document. If column child elements are present, their color
attribute are used for defining color of column highlighting.