| 1 | ########################################################################## | ||
| 2 | # | ||
| 3 | # $Id: XMLReport.pm,v 1.7 2006/09/17 19:18:35 pkaluski Exp $ | ||
| 4 | # $Name: Stable_0_16 $ | ||
| 5 | # | ||
| 6 | # Object of this class creates an XML report from csv dumps. | ||
| 7 | # | ||
| 8 | # $Log: XMLReport.pm,v $ | ||
| 9 | # Revision 1.7 2006/09/17 19:18:35 pkaluski | ||
| 10 | # Adjusted command line options to new key definitions | ||
| 11 | # | ||
| 12 | # Revision 1.6 2006/04/09 15:42:19 pkaluski | ||
| 13 | # Small code clean-up. Each module has comprehensive POD | ||
| 14 | # | ||
| 15 | # Revision 1.5 2006/02/10 22:32:16 pkaluski | ||
| 16 | # Major redesign in progress. Updated POD. Works. | ||
| 17 | # | ||
| 18 | # Revision 1.4 2006/01/21 20:39:47 pkaluski | ||
| 19 | # Improved lcsvdiff output format | ||
| 20 | # | ||
| 21 | # Revision 1.3 2006/01/14 12:52:33 pkaluski | ||
| 22 | # New tool design in progress | ||
| 23 | # | ||
| 24 | # Revision 1.2 2006/01/07 22:56:17 pkaluski | ||
| 25 | # Redesigned simple reporting works. Diff reports still to be implemented. | ||
| 26 | # | ||
| 27 | # Revision 1.1 2006/01/07 21:59:28 pkaluski | ||
| 28 | # Initial revision. Works. | ||
| 29 | # | ||
| 30 | # | ||
| 31 | ########################################################################## | ||
| 32 | package LRpt::XMLReport; | ||
| 33 | |||
| 34 | use strict; | ||
| 35 | use Getopt::Long; | ||
| 36 | use LRpt::Config; | ||
| 37 | use LRpt::Collection; | ||
| 38 | use LRpt::JarReader; | ||
| 39 | use LRpt::RKeysRdr; | ||
| 40 | use File::Basename; | ||
| 41 | |||
| 42 | use vars qw( @EXPORT @ISA ); | ||
| 43 | @ISA = qw( Exporter ); | ||
| 44 | @EXPORT = qw( create_report ); | ||
| 45 | |||
| 46 | our %all_rows = (); | ||
| 47 | our %metadata = (); | ||
| 48 | our $rldf = ""; | ||
| 49 | our @report = (); | ||
| 50 | |||
| 51 | our $stmt_fname = ""; | ||
| 52 | our $diffs = ""; | ||
| 53 | |||
| 54 | our $rkeys_rdr = ""; | ||
| 55 | |||
| 56 | =head1 NAME | ||
| 57 | |||
| 58 | LRpt::XMLReport - A module for converting outputs generated by | ||
| 59 | LReport tools to XML format. | ||
| 60 | |||
| 61 | =head1 SYNOPSIS | ||
| 62 | |||
| 63 | lrptxml.pl --selects=selects.txt --keys_file=keys.txt data | ||
| 64 | |||
| 65 | lrptxml.pl --diffs --selects=selects.txt --keys_file=rkeys.txt diffs.txt | ||
| 66 | |||
| 67 | =head1 DESCRIPTION | ||
| 68 | |||
| 69 | C<LRpt::XMLReport> is a part of L<C<LRpt>|LRpt> (B<LReport>) library. | ||
| 70 | It used to convert outputs generated by other tools from B<LReport> suite to | ||
| 71 | I<XML> format. You should not call this class directly from your code. | ||
| 72 | Instead you should use B<lrptxml.pl> tool, which is a simple wrapper around | ||
| 73 | this module. It looks like this: | ||
| 74 | |||
| 75 | use strict; | ||
| 76 | use LRpt::XMLReport; | ||
| 77 | |||
| 78 | create_report( @ARGV ); | ||
| 79 | |||
| 80 | |||
| 81 | =head1 COMMAND LINE SWITCHES | ||
| 82 | |||
| 83 | =over 4 | ||
| 84 | |||
| 85 | =item --selects=file | ||
| 86 | |||
| 87 | Optional. Name of a selects file (see doc). They are included in the | ||
| 88 | report for a select of corresponding name. If selects are not given, report | ||
| 89 | will not contain selects. | ||
| 90 | |||
| 91 | =item --diffs | ||
| 92 | |||
| 93 | Switches working mode to read output of B<lcsvdiff.pl>. If not given | ||
| 94 | the working mode is reading I<csv> files from a directory | ||
| 95 | |||
| 96 | =item --keys_file=keys_file | ||
| 97 | |||
| 98 | File name containing row key definitions. | ||
| 99 | |||
| 100 | =back | ||
| 101 | |||
| 102 | =head1 HOW IS THIS MANUAL ORGANIZED | ||
| 103 | |||
| 104 | On this page you will find details on C<LRpt::XMLReport> package. You also find | ||
| 105 | details on how to use B<LReport> tools for reporting. | ||
| 106 | |||
| 107 | Firstly you will find a list all methods provided by the class. | ||
| 108 | |||
| 109 | Then I will show you a step by step example, in which I will explain you | ||
| 110 | what can be done and how it can be done. | ||
| 111 | |||
| 112 | Then I will give some additional details, which I did not include in | ||
| 113 | the example to avoid making it too complex. | ||
| 114 | |||
| 115 | On the end I will describe existing XSLT stylesheets for converting I<XML> | ||
| 116 | reports to other formats. Currently only conversion to RTF is available. | ||
| 117 | |||
| 118 | =head1 METHODS | ||
| 119 | |||
| 120 | In this sections you will find a more or less complete listing of all | ||
| 121 | methods provided by the package. | ||
| 122 | |||
| 123 | =cut | ||
| 124 | |||
| 125 | ######################################################################## | ||
| 126 | |||
| 127 | =head2 C<create_report> | ||
| 128 | |||
| 129 | create_report( @ARGV ); | ||
| 130 | |||
| 131 | Main public function. The only one exported. See | ||
| 132 | L</COMMAND LINE SWITCHES> for meaning of parameters. | ||
| 133 | |||
| 134 | =cut | ||
| 135 | |||
| 136 | ######################################################################## | ||
| 137 | sub create_report | ||
| 138 | { | ||
| 139 | local ( @ARGV ) = @_; | ||
| 140 | my @key = (); | ||
| 141 | my @key_cols = (); | ||
| 142 | my $keys_file; | ||
| 143 | my $global_keys; | ||
| 144 | my $help = ""; | ||
| 145 | GetOptions( "selects=s" => \$stmt_fname, | ||
| 146 | "diffs" => \$diffs, | ||
| 147 | "help" => \$help, | ||
| 148 | "key=s" => \@key, | ||
| 149 | "key_cols=s" => \@key_cols, | ||
| 150 | "keys_file=s" => \$keys_file, | ||
| 151 | "global_keys" => \$global_keys ); | ||
| 152 | |||
| 153 | if( $help ){ | ||
| 154 | print_usage(); | ||
| 155 | } | ||
| 156 | |||
| 157 | if( @key or $keys_file or @key_cols ){ | ||
| 158 | $rkeys_rdr = LRpt::RKeysRdr->new( 'fname' => $keys_file, | ||
| 159 | 'key' => \@key, | ||
| 160 | 'key_cols' => \@key_cols, | ||
| 161 | 'global_keys' => $global_keys ); | ||
| 162 | } | ||
| 163 | |||
| 164 | if( $diffs ){ | ||
| 165 | load_diffs(); | ||
| 166 | }else{ | ||
| 167 | load_csvs(); | ||
| 168 | } | ||
| 169 | generate_report(); | ||
| 170 | print "\n"; | ||
| 171 | } | ||
| 172 | |||
| 173 | ######################################################################## | ||
| 174 | |||
| 175 | =head2 C<load_diffs> | ||
| 176 | |||
| 177 | load_diffs(); | ||
| 178 | |||
| 179 | Loads input data from files generated by L<C<LRpt::CSVDiff>|LRpt::CSVDiff> | ||
| 180 | module. | ||
| 181 | |||
| 182 | =cut | ||
| 183 | |||
| 184 | ######################################################################## | ||
| 185 | sub load_diffs | ||
| 186 | { | ||
| 187 | my $line = undef; | ||
| 188 | my $file = ""; | ||
| 189 | my $config = LRpt::Config->new(); | ||
| 190 | my $ext = $config->get_value( 'ext' ); | ||
| 191 | MAIN: while( $line = <> ){ | ||
| 192 | if( $line =~ /lcsvdiff (\S+) (\S+)/ ){ | ||
| 193 | $file = $1; | ||
| 194 | my $name = basename( $file ); | ||
| 195 | $name =~ s/\.$ext$//; | ||
| 196 | $line = load_one_select( $name ); | ||
| 197 | redo MAIN; | ||
| 198 | }elsif( !$line ){ | ||
| 199 | return; | ||
| 200 | } | ||
| 201 | else{ | ||
| 202 | die "Unexpected line $line"; | ||
| 203 | } | ||
| 204 | } | ||
| 205 | } | ||
| 206 | |||
| 207 | ######################################################################## | ||
| 208 | |||
| 209 | =head2 C<load_one_select> | ||
| 210 | |||
| 211 | load_one_select(); | ||
| 212 | |||
| 213 | Loads one select from the input diff file. | ||
| 214 | |||
| 215 | =cut | ||
| 216 | |||
| 217 | ######################################################################## | ||
| 218 | sub load_one_select | ||
| 219 | { | ||
| 220 | my $file = shift; | ||
| 221 | my $line = <>; | ||
| 222 | my $cols_string = ( $line =~ /^SCHEMA: (.*)$/ )[ 0 ]; | ||
| 223 | if( not $cols_string ) { | ||
| 224 | die "Expected SCHEMA line not given"; | ||
| 225 | }else{ | ||
| 226 | $LRpt::XMLReport::metadata{ $file } = [ split( /\t/, $cols_string ) ]; | ||
| 227 | } | ||
| 228 | LINE: while( $line = <> ){ | ||
| 229 | if( $line =~ /^ROW\( .* \): .*$/ ){ | ||
| 230 | $line = load_ROW_entry( $line, $file ); | ||
| 231 | if( not defined $line ){ | ||
| 232 | return undef; | ||
| 233 | }else{ | ||
| 234 | redo LINE; | ||
| 235 | } | ||
| 236 | # }elsif( $line =~ /^UPD\( .* \): \w+: .*$/ ){ | ||
| 237 | # $line = load_UPD_entry( $line, $file ); | ||
| 238 | }elsif( $line =~ /^DEL\( .* \): .*$/ ){ | ||
| 239 | load_DEL_entry( $line, $file ); | ||
| 240 | }elsif( $line =~ /^INS\( .* \): .*$/ ){ | ||
| 241 | load_INS_entry( $line, $file ); | ||
| 242 | }else{ | ||
| 243 | return $line; | ||
| 244 | } | ||
| 245 | } | ||
| 246 | return undef; | ||
| 247 | } | ||
| 248 | |||
| 249 | ######################################################################## | ||
| 250 | |||
| 251 | =head2 C<load_ROW_entry> | ||
| 252 | |||
| 253 | load_ROW_entry( $line, $file ); | ||
| 254 | |||
| 255 | Loads one ROW type entry from the diff file. | ||
| 256 | |||
| 257 | =cut | ||
| 258 | |||
| 259 | ######################################################################## | ||
| 260 | sub load_ROW_entry | ||
| 261 | { | ||
| 262 | my $line = shift; | ||
| 263 | my $file = shift; | ||
| 264 | my $row = {}; | ||
| 265 | |||
| 266 | my ( $rkey, $values_string ) = | ||
| 267 | ( $line =~ /^ROW\( (.*) \): (.*)$/ )[ 0, 1 ]; | ||
| 268 | |||
| 269 | my @values = split( /\t/, $values_string ); | ||
| 270 | my @cols = @{ $LRpt::XMLReport::metadata{ $file } }; | ||
| 271 | @$row{ @cols } = @values; | ||
| 272 | |||
| 273 | my $col; | ||
| 274 | my $value; | ||
| 275 | my $diff_found = 0; | ||
| 276 | while( $line = <> ){ | ||
| 277 | ( $rkey, $col, $value ) = | ||
| 278 | ( $line =~ /^UPD\( (.*) \): (\w+): (.*)$/ )[ 0, 1, 2 ]; | ||
| 279 | if( $rkey ){ | ||
| 280 | $diff_found = 1; | ||
| 281 | my ( $old_value, $new_value ) = | ||
| 282 | ( $value =~ /^(.*) ==#> (.*)$/ )[ 0, 1 ]; | ||
| 283 | delete $row->{ $col }; | ||
| 284 | $row->{ $col }->{ 'old_value' } = $old_value; | ||
| 285 | $row->{ $col }->{ 'new_value' } = $new_value; | ||
| 286 | next; | ||
| 287 | }else{ | ||
| 288 | if( $diff_found ){ | ||
| 289 | include_in_report( $file, $row, "different" ); | ||
| 290 | }else{ | ||
| 291 | include_in_report( $file, $row, "equal" ); | ||
| 292 | } | ||
| 293 | return $line; | ||
| 294 | } | ||
| 295 | } | ||
| 296 | |||
| 297 | if( $diff_found ){ | ||
| 298 | include_in_report( $file, $row, "different" ); | ||
| 299 | }else{ | ||
| 300 | include_in_report( $file, $row, "equal" ); | ||
| 301 | } | ||
| 302 | return undef; | ||
| 303 | } | ||
| 304 | |||
| 305 | ######################################################################## | ||
| 306 | |||
| 307 | =head2 C<load_DEL_entry> | ||
| 308 | |||
| 309 | load_DEL_entry( $line, $file ); | ||
| 310 | |||
| 311 | Loads one DEL type entry from the diff file. | ||
| 312 | |||
| 313 | =cut | ||
| 314 | |||
| 315 | ######################################################################## | ||
| 316 | sub load_DEL_entry | ||
| 317 | { | ||
| 318 | my $line = shift; | ||
| 319 | my $file = shift; | ||
| 320 | my $row = {}; | ||
| 321 | my $stored_rkey = ""; | ||
| 322 | |||
| 323 | my ( $rkey, $values_string ) = | ||
| 324 | ( $line =~ /^DEL\( (.*) \): (.*)$/ )[ 0, 1 ]; | ||
| 325 | |||
| 326 | my @values = split( /\t/, $values_string ); | ||
| 327 | my @cols = @{ $LRpt::XMLReport::metadata{ $file } }; | ||
| 328 | @$row{ @cols } = @values; | ||
| 329 | |||
| 330 | include_in_report( $file, $row, "missing" ); | ||
| 331 | } | ||
| 332 | |||
| 333 | ######################################################################## | ||
| 334 | |||
| 335 | =head2 C<load_INS_entry> | ||
| 336 | |||
| 337 | load_INS_entry( $line, $file ); | ||
| 338 | |||
| 339 | Loads one INS type entry from the diff file. | ||
| 340 | |||
| 341 | =cut | ||
| 342 | |||
| 343 | ######################################################################## | ||
| 344 | sub load_INS_entry | ||
| 345 | { | ||
| 346 | my $line = shift; | ||
| 347 | my $file = shift; | ||
| 348 | my $row = {}; | ||
| 349 | my $stored_rkey = ""; | ||
| 350 | |||
| 351 | my ( $rkey, $values_string ) = | ||
| 352 | ( $line =~ /^INS\( (.*) \): (.*)$/ )[ 0, 1 ]; | ||
| 353 | |||
| 354 | my @values = split( /\t/, $values_string ); | ||
| 355 | my @cols = @{ $LRpt::XMLReport::metadata{ $file } }; | ||
| 356 | @$row{ @cols } = @values; | ||
| 357 | |||
| 358 | include_in_report( $file, $row, "additional" ); | ||
| 359 | } | ||
| 360 | |||
| 361 | ######################################################################## | ||
| 362 | |||
| 363 | =head2 C<load_csvs> | ||
| 364 | |||
| 365 | load_csvs(); | ||
| 366 | |||
| 367 | Loads data from csv files | ||
| 368 | |||
| 369 | =cut | ||
| 370 | |||
| 371 | ######################################################################## | ||
| 372 | sub load_csvs | ||
| 373 | { | ||
| 374 | my $file = ""; | ||
| 375 | my @files = (); | ||
| 376 | if( !@ARGV ){ | ||
| 377 | die "CSV files names not given"; | ||
| 378 | }else{ | ||
| 379 | $file = shift( @ARGV ); | ||
| 380 | if( -d $file ){ | ||
| 381 | if( @ARGV ){ | ||
| 382 | die "When directory name given, other files " . | ||
| 383 | "must not be specified"; | ||
| 384 | }else{ | ||
| 385 | my $config = LRpt::Config->new(); | ||
| 386 | my $ext = $config->get_value( 'ext' ); | ||
| 387 | @files = glob( "$file/*.$ext" ); | ||
| 388 | } | ||
| 389 | }else{ | ||
| 390 | while( $file = shift( @ARGV ) ){ | ||
| 391 | if( -f $file ){ | ||
| 392 | die "No such file $file"; | ||
| 393 | } | ||
| 394 | push( @files, $file ); | ||
| 395 | } | ||
| 396 | } | ||
| 397 | } | ||
| 398 | foreach $file ( @files ){ | ||
| 399 | load_csv_file( $file ); | ||
| 400 | } | ||
| 401 | } | ||
| 402 | |||
| 403 | ######################################################################## | ||
| 404 | |||
| 405 | =head2 C<load_csv_file> | ||
| 406 | |||
| 407 | load_csv_file(); | ||
| 408 | |||
| 409 | Loads data from one csv file | ||
| 410 | |||
| 411 | =cut | ||
| 412 | |||
| 413 | ######################################################################## | ||
| 414 | sub load_csv_file | ||
| 415 | { | ||
| 416 | my $file = shift; | ||
| 417 | my $config = LRpt::Config->new(); | ||
| 418 | my $ext = $config->get_value( 'ext' ); | ||
| 419 | my $name = basename( $file ); | ||
| 420 | $name =~ s/\.$ext$//; | ||
| 421 | my $coll = ""; | ||
| 422 | my $rkey = ""; | ||
| 423 | if( $rkeys_rdr and $rkey = $rkeys_rdr->find_key( $name ) ){ | ||
| 424 | $coll = LRpt::Collection->new_from_csv( 'name' => $name, | ||
| 425 | 'data_file' => $file, | ||
| 426 | 'key' => $rkey ); | ||
| 427 | }else{ | ||
| 428 | $coll = LRpt::Collection->new_from_csv( 'name' => $name, | ||
| 429 | 'data_file' => $file ); | ||
| 430 | } | ||
| 431 | |||
| 432 | $metadata{ $name } = $coll->get_columns(); | ||
| 433 | if( $rkey ){ | ||
| 434 | my @rkey_values = sort $coll->get_key_values(); | ||
| 435 | if( ! @rkey_values ){ | ||
| 436 | $all_rows{ $name } = []; | ||
| 437 | }else{ | ||
| 438 | foreach my $value ( @rkey_values ){ | ||
| 439 | include_in_report( $name, $coll->get_row( $value ), 'equal' ); | ||
| 440 | } | ||
| 441 | } | ||
| 442 | }else{ | ||
| 443 | my $rows = $coll->get_all_rows(); | ||
| 444 | if( ! @$rows ){ | ||
| 445 | $all_rows{ $name } = []; | ||
| 446 | }else{ | ||
| 447 | foreach my $row ( @$rows ){ | ||
| 448 | include_in_report( $name, $row, 'equal' ); | ||
| 449 | } | ||
| 450 | } | ||
| 451 | } | ||
| 452 | } | ||
| 453 | |||
| 454 | ######################################################################## | ||
| 455 | |||
| 456 | =head2 C<include_in_report> | ||
| 457 | |||
| 458 | include_in_report( $name, $row, $type ); | ||
| 459 | |||
| 460 | Adds a row to a list, which will be used for report generation | ||
| 461 | |||
| 462 | =cut | ||
| 463 | |||
| 464 | ######################################################################## | ||
| 465 | sub include_in_report | ||
| 466 | { | ||
| 467 | my $name = shift; | ||
| 468 | my $row = shift; | ||
| 469 | my $type = shift; | ||
| 470 | |||
| 471 | if( not exists $all_rows{ $name } ){ | ||
| 472 | $all_rows{ $name } = []; | ||
| 473 | } | ||
| 474 | if( $type eq "equal" ){ | ||
| 475 | push( @{ $all_rows{ $name } }, [ $row, 'equal' ] ); | ||
| 476 | } | ||
| 477 | if( $type eq "different" ){ | ||
| 478 | push( @{ $all_rows{ $name } }, [ $row, 'different' ] ); | ||
| 479 | } | ||
| 480 | if( $type eq "additional" ){ | ||
| 481 | push( @{ $all_rows{ $name } }, [ $row, 'additional' ] ); | ||
| 482 | } | ||
| 483 | if( $type eq "missing" ){ | ||
| 484 | push( @{ $all_rows{ $name } }, [ $row, 'missing' ] ); | ||
| 485 | } | ||
| 486 | } | ||
| 487 | |||
| 488 | ######################################################################## | ||
| 489 | |||
| 490 | =head2 C<generate_report> | ||
| 491 | |||
| 492 | generate_report(); | ||
| 493 | |||
| 494 | Generate XML report. | ||
| 495 | |||
| 496 | =cut | ||
| 497 | |||
| 498 | ######################################################################## | ||
| 499 | sub generate_report | ||
| 500 | { | ||
| 501 | foreach my $select ( sort keys %all_rows ){ | ||
| 502 | process_data( $select ); | ||
| 503 | } | ||
| 504 | print_report(); | ||
| 505 | } | ||
| 506 | |||
| 507 | ######################################################################## | ||
| 508 | |||
| 509 | =head2 C<process_data> | ||
| 510 | |||
| 511 | process_data( $select ); | ||
| 512 | |||
| 513 | Creates report for one select | ||
| 514 | |||
| 515 | =cut | ||
| 516 | |||
| 517 | ######################################################################## | ||
| 518 | sub process_data | ||
| 519 | { | ||
| 520 | my $select = shift; | ||
| 521 | my $data = $all_rows{ $select }; | ||
| 522 | |||
| 523 | my @rows = (); | ||
| 524 | foreach my $item ( @$data ){ | ||
| 525 | my ( $row, $type ) = @$item; | ||
| 526 | push( @rows, process_row( $select, $item ) ); | ||
| 527 | } | ||
| 528 | push( @report, [ $select, \@rows ] ); | ||
| 529 | } | ||
| 530 | |||
| 531 | ######################################################################## | ||
| 532 | |||
| 533 | =head2 C<process_row> | ||
| 534 | |||
| 535 | process_row( $select, $item ); | ||
| 536 | |||
| 537 | Creates entry for one row | ||
| 538 | |||
| 539 | =cut | ||
| 540 | |||
| 541 | ######################################################################## | ||
| 542 | sub process_row | ||
| 543 | { | ||
| 544 | my $select = shift; | ||
| 545 | my $item = shift; | ||
| 546 | |||
| 547 | my ( $row, $type ) = @$item; | ||
| 548 | |||
| 549 | my @cols = @{ $metadata{ $select } }; | ||
| 550 | my @rpt_row = (); | ||
| 551 | if( $type eq "equal" ){ | ||
| 552 | foreach my $col ( @cols ){ | ||
| 553 | push( @rpt_row, [ $col, $row->{ $col } ] ); | ||
| 554 | } | ||
| 555 | return [ 'equal', \@rpt_row ]; | ||
| 556 | } | ||
| 557 | if( $type eq "different" ){ | ||
| 558 | foreach my $col ( @cols ){ | ||
| 559 | if( ref( $row->{ $col } ) eq "HASH" ){ | ||
| 560 | push( @rpt_row, [ $col, { | ||
| 561 | 'old' => $row->{ $col }->{ 'old_value' }, | ||
| 562 | 'new' => $row->{ $col }->{ 'new_value' } | ||
| 563 | } | ||
| 564 | ] ); | ||
| 565 | }else{ | ||
| 566 | push( @rpt_row, [ $col, $row->{ $col } ] ); | ||
| 567 | } | ||
| 568 | } | ||
| 569 | return [ 'different', \@rpt_row ]; | ||
| 570 | } | ||
| 571 | if( $type eq "additional" ){ | ||
| 572 | foreach my $col ( @cols ){ | ||
| 573 | push( @rpt_row, [ $col, $row->{ $col } ] ); | ||
| 574 | } | ||
| 575 | return [ 'additional', \@rpt_row ]; | ||
| 576 | } | ||
| 577 | if( $type eq "missing" ){ | ||
| 578 | foreach my $col ( @cols ){ | ||
| 579 | push( @rpt_row, [ $col, $row->{ $col } ] ); | ||
| 580 | } | ||
| 581 | return [ 'missing', \@rpt_row ]; | ||
| 582 | } | ||
| 583 | } | ||
| 584 | |||
| 585 | ######################################################################## | ||
| 586 | |||
| 587 | =head2 C<print_report> | ||
| 588 | |||
| 589 | print_report(); | ||
| 590 | |||
| 591 | Prints report to the standard output. | ||
| 592 | |||
| 593 | =cut | ||
| 594 | |||
| 595 | ######################################################################## | ||
| 596 | sub print_report | ||
| 597 | { | ||
| 598 | print "<report>\n"; | ||
| 599 | foreach my $select ( @report ){ | ||
| 600 | print_select( $select ); | ||
| 601 | } | ||
| 602 | print "</report>\n"; | ||
| 603 | } | ||
| 604 | |||
| 605 | ######################################################################## | ||
| 606 | |||
| 607 | =head2 C<print_select> | ||
| 608 | |||
| 609 | print_select(); | ||
| 610 | |||
| 611 | Formats one select for XML | ||
| 612 | |||
| 613 | =cut | ||
| 614 | |||
| 615 | ######################################################################## | ||
| 616 | sub print_select | ||
| 617 | { | ||
| 618 | my $select = shift; | ||
| 619 | print " <" . $select->[ 0 ] . ">\n"; | ||
| 620 | print_statement( $select->[ 0 ] ); | ||
| 621 | print_header( $select->[ 0 ] ); | ||
| 622 | print_data( $select ); | ||
| 623 | print " </" . $select->[ 0 ] . ">\n"; | ||
| 624 | } | ||
| 625 | |||
| 626 | |||
| 627 | ######################################################################## | ||
| 628 | |||
| 629 | =head2 C<print_header> | ||
| 630 | |||
| 631 | print_header(); | ||
| 632 | |||
| 633 | Formats one header for XML | ||
| 634 | |||
| 635 | =cut | ||
| 636 | |||
| 637 | ######################################################################## | ||
| 638 | sub print_header | ||
| 639 | { | ||
| 640 | my $select = shift; | ||
| 641 | print " <header>\n"; | ||
| 642 | foreach my $col ( @{ $metadata{ $select } } ){ | ||
| 643 | print " " x 12 . "<$col/>\n"; | ||
| 644 | } | ||
| 645 | print " </header>\n"; | ||
| 646 | } | ||
| 647 | |||
| 648 | ######################################################################## | ||
| 649 | |||
| 650 | =head2 C<print_data> | ||
| 651 | |||
| 652 | print_data(); | ||
| 653 | |||
| 654 | Formats one data section for XML | ||
| 655 | |||
| 656 | =cut | ||
| 657 | |||
| 658 | ######################################################################## | ||
| 659 | sub print_data | ||
| 660 | { | ||
| 661 | my $select = shift; | ||
| 662 | print " <data>\n"; | ||
| 663 | foreach my $row ( @{ $select->[ 1 ] } ){ | ||
| 664 | if( $row->[ 0 ] eq 'equal' ){ | ||
| 665 | print_row( $row, 'equal' ); | ||
| 666 | } | ||
| 667 | if( $row->[ 0 ] eq 'additional' ){ | ||
| 668 | print_row( $row, 'additional' ); | ||
| 669 | } | ||
| 670 | if( $row->[ 0 ] eq 'missing' ){ | ||
| 671 | print_row( $row, 'missing' ); | ||
| 672 | } | ||
| 673 | if( $row->[ 0 ] eq 'different' ){ | ||
| 674 | print_different_row( $row ); | ||
| 675 | } | ||
| 676 | } | ||
| 677 | print " </data>\n"; | ||
| 678 | } | ||
| 679 | |||
| 680 | ######################################################################## | ||
| 681 | |||
| 682 | =head2 C<print_row> | ||
| 683 | |||
| 684 | print_row(); | ||
| 685 | |||
| 686 | Formats one row for XML | ||
| 687 | |||
| 688 | =cut | ||
| 689 | |||
| 690 | ######################################################################## | ||
| 691 | sub print_row | ||
| 692 | { | ||
| 693 | my $row = shift; | ||
| 694 | my $type = shift; | ||
| 695 | print " " x 12 . "<$type>\n"; | ||
| 696 | foreach my $col ( @{ $row->[ 1 ] } ){ | ||
| 697 | print " " x 16 . "<" . $col->[ 0 ] . ">"; | ||
| 698 | print_value( $col->[ 1 ] ); | ||
| 699 | print "</" . $col->[ 0 ] . ">\n"; | ||
| 700 | } | ||
| 701 | print " " x 12 . "</$type>\n"; | ||
| 702 | } | ||
| 703 | |||
| 704 | ######################################################################## | ||
| 705 | |||
| 706 | =head2 C<print_value> | ||
| 707 | |||
| 708 | print_value(); | ||
| 709 | |||
| 710 | Formats one value for XML | ||
| 711 | |||
| 712 | =cut | ||
| 713 | |||
| 714 | ######################################################################## | ||
| 715 | sub print_value | ||
| 716 | { | ||
| 717 | my $value = shift; | ||
| 718 | if( $value =~ /\&|</ ){ | ||
| 719 | print "<![CDATA[" . $value . "]]>"; | ||
| 720 | }else{ | ||
| 721 | print $value; | ||
| 722 | } | ||
| 723 | } | ||
| 724 | |||
| 725 | |||
| 726 | ######################################################################## | ||
| 727 | |||
| 728 | =head2 C<print_different_row> | ||
| 729 | |||
| 730 | print_different_row(); | ||
| 731 | |||
| 732 | Formats one different row for XML | ||
| 733 | |||
| 734 | =cut | ||
| 735 | |||
| 736 | ######################################################################## | ||
| 737 | sub print_different_row | ||
| 738 | { | ||
| 739 | my $row = shift; | ||
| 740 | print " " x 12 . "<different>\n"; | ||
| 741 | foreach my $col ( @{ $row->[ 1 ] } ){ | ||
| 742 | print " " x 16 . "<" . $col->[ 0 ] . ">"; | ||
| 743 | if( ref( $col->[ 1 ] ) ne "HASH" ){ | ||
| 744 | print_value( $col->[ 1 ] ); | ||
| 745 | print "</" . $col->[ 0 ] . ">\n"; | ||
| 746 | }else{ | ||
| 747 | print "\n" . " " x 20 . "<old_value>"; | ||
| 748 | print_value( $col->[ 1 ]->{ 'old' } ); | ||
| 749 | print "</old_value>\n"; | ||
| 750 | print " " x 20 . "<new_value>"; | ||
| 751 | print_value( $col->[ 1 ]->{ 'new' } ); | ||
| 752 | print "</new_value>\n"; | ||
| 753 | print " " x 16 . "</" . $col->[ 0 ] . ">\n"; | ||
| 754 | } | ||
| 755 | } | ||
| 756 | print " " x 12 . "</different>\n"; | ||
| 757 | } | ||
| 758 | |||
| 759 | |||
| 760 | ######################################################################## | ||
| 761 | |||
| 762 | =head2 C<print_statement> | ||
| 763 | |||
| 764 | print_statement(); | ||
| 765 | |||
| 766 | Adds details of select statement to the report | ||
| 767 | |||
| 768 | =cut | ||
| 769 | |||
| 770 | ######################################################################## | ||
| 771 | sub print_statement | ||
| 772 | { | ||
| 773 | my $select = shift; | ||
| 774 | my @stmt_rules = ( { 'name' => 'name' }, | ||
| 775 | { 'name' => 'select' } ); | ||
| 776 | |||
| 777 | if( !$stmt_fname ){ | ||
| 778 | return; | ||
| 779 | }else{ | ||
| 780 | my $jr = LRpt::JarReader->new( 'rules' => \@stmt_rules, | ||
| 781 | 'filename' => $stmt_fname ); | ||
| 782 | $jr->read_all(); | ||
| 783 | my $sect = $jr->get_section_with( 'name' => $select ); | ||
| 784 | print " " x 8 . "<statement><![CDATA[" . | ||
| 785 | $sect->{ 'select' } . "]]></statement>\n"; | ||
| 786 | } | ||
| 787 | } | ||
| 788 | |||
| 789 | ###################################################################### | ||
| 790 | |||
| 791 | =head2 C<print_usage> | ||
| 792 | |||
| 793 | print_usage(); | ||
| 794 | |||
| 795 | Prints usage text. | ||
| 796 | |||
| 797 | =cut | ||
| 798 | |||
| 799 | ###################################################################### | ||
| 800 | sub print_usage | ||
| 801 | { | ||
| 802 | print "Usage: $0 --help \n"; | ||
| 803 | print " --selects=<name> --rkeys_file=<name>" . | ||
| 804 | " --diffs file_name\n"; | ||
| 805 | print "\n"; | ||
| 806 | print " --diffs - Sets input file mode to diffs\n"; | ||
| 807 | print " --help - prints this help screen\n"; | ||
| 808 | print " --rkeys_file - Name of the file containing row keys " . | ||
| 809 | "definitions\n"; | ||
| 810 | print " --selects - Name of a file containing selects to be\n" . | ||
| 811 | " executed.\n"; | ||
| 812 | print " file_name - Name of a file or a folder containing data\n" . | ||
| 813 | " to be reported.\n"; | ||
| 814 | exit( 0 ); | ||
| 815 | } | ||
| 816 | |||
| 817 | =head1 REPORTING AND FORMATING IN LREPORT | ||
| 818 | |||
| 819 | This chapter is supposed to help you to understand how B<LReport> helps | ||
| 820 | you in generating nicely formated reports of database contents and | ||
| 821 | differences. | ||
| 822 | |||
| 823 | We will start by an example | ||
| 824 | |||
| 825 | =head2 EXAMPLE 1 | ||
| 826 | |||
| 827 | We will continue using an example from manual page for L<C<LRpt>|LRpt>. | ||
| 828 | Our goal would be to generate | ||
| 829 | an RTF document, which looks like the one given at http:/xxxx. | ||
| 830 | |||
| 831 | As you remember, we finished with the output of B<lcsvdiff.pm> | ||
| 832 | |||
| 833 | We will create an XML document and then we will process it with | ||
| 834 | XSLT processor to get a final RTF document. | ||
| 835 | |||
| 836 | One of possible inputs for B<lrptxml.pm> is output generated by | ||
| 837 | B<lcsvdiff.pm>. However, this is not exactly the format generated in the | ||
| 838 | example shown in L<C<LRpt>|LRpt> manual page. The format used there, contained | ||
| 839 | only information about changes. In order to generate a full report we will | ||
| 840 | have to use I<--all> switch when calling B<lcsvdiff.pm>. This switch | ||
| 841 | will generate the following output: | ||
| 842 | |||
| 843 | lcsvdiff.pl before/customer.txt after/customer.txt | ||
| 844 | SCHEMA: customer_id name last_name address | ||
| 845 | ROW( 1234 ): 1234 Jan Nowak Warszawa | ||
| 846 | lcsvdiff.pl before/service.txt after/service.txt | ||
| 847 | SCHEMA: customer_id service_type price status | ||
| 848 | INS( 1234#GPRS ): 1234 GPRS 2.05 ACTIVE | ||
| 849 | DEL( 1234#MAIL ): 1234 MAIL 1.30 ACTIVE | ||
| 850 | ROW( 1234#VOICE ): 1234 VOICE 0.34 DEACTIVATED | ||
| 851 | UPD( 1234#VOICE ): status: ACTIVE =#=> DEACTIVATED | ||
| 852 | |||
| 853 | As you can see, differences are reported together with information about | ||
| 854 | all rows returned by selects. | ||
| 855 | |||
| 856 | You run B<lrptxml.pl> in the following way | ||
| 857 | |||
| 858 | lrptxml.pl --diffs --selects=selects.txt --rkeys_file=rkeys.txt diffs.txt | ||
| 859 | |||
| 860 | Meaning of parameters: | ||
| 861 | |||
| 862 | =over 4 | ||
| 863 | |||
| 864 | =item --diffs | ||
| 865 | |||
| 866 | A switch indicating that a XML report should be generated from output of | ||
| 867 | B<lcsvdiff.pl> tool. | ||
| 868 | |||
| 869 | =item --selects | ||
| 870 | |||
| 871 | A file containing selects. This is the same file as used by B<lcsvdmp.pl>. | ||
| 872 | It is used here to include in XML report the full text of select, which | ||
| 873 | returned presented rows | ||
| 874 | |||
| 875 | =item --rkeys_file | ||
| 876 | |||
| 877 | File with a definiton of row keys. This is exactly the same type of file | ||
| 878 | as used by B<lcsvdiff.pl> tool. It is used here to order rows in the report | ||
| 879 | properly. | ||
| 880 | |||
| 881 | =item diffs.txt | ||
| 882 | |||
| 883 | Output generated by B<lcsvdiff.pl> ran with I<--all> switch. | ||
| 884 | |||
| 885 | =back | ||
| 886 | |||
| 887 | The output of B<lrptxml.pl> should look like this: | ||
| 888 | |||
| 889 | <report> | ||
| 890 | <customer> | ||
| 891 | <statement><![CDATA[select * from customer where customer_id = 1234]]> | ||
| 892 | </statement> | ||
| 893 | <header> | ||
| 894 | <customer_id/> | ||
| 895 | <name/> | ||
| 896 | <last_name/> | ||
| 897 | <address/> | ||
| 898 | </header> | ||
| 899 | <data> | ||
| 900 | <equal> | ||
| 901 | <customer_id>1234</customer_id> | ||
| 902 | <name>Jan</name> | ||
| 903 | <last_name>Nowak</last_name> | ||
| 904 | <address>Warszawa</address> | ||
| 905 | </equal> | ||
| 906 | </data> | ||
| 907 | </customer> | ||
| 908 | <service> | ||
| 909 | <statement><![CDATA[select * from service where customer_id = 1234]]> | ||
| 910 | </statement> | ||
| 911 | <header> | ||
| 912 | <customer_id/> | ||
| 913 | <service_type/> | ||
| 914 | <price/> | ||
| 915 | <status/> | ||
| 916 | </header> | ||
| 917 | <data> | ||
| 918 | <additional> | ||
| 919 | <customer_id>1234</customer_id> | ||
| 920 | <service_type>GPRS</service_type> | ||
| 921 | <price>2.05</price> | ||
| 922 | <status>ACTIVE</status> | ||
| 923 | </additional> | ||
| 924 | <missing> | ||
| 925 | <customer_id>1234</customer_id> | ||
| 926 | <service_type>MAIL</service_type> | ||
| 927 | <price>1.30</price> | ||
| 928 | <status>ACTIVE</status> | ||
| 929 | </missing> | ||
| 930 | <different> | ||
| 931 | <customer_id>1234</customer_id> | ||
| 932 | <service_type>VOICE</service_type> | ||
| 933 | <price>0.34</price> | ||
| 934 | <status> | ||
| 935 | <old_value>ACTIVE</old_value> | ||
| 936 | <new_value>DEACTIVATED</new_value> | ||
| 937 | </status> | ||
| 938 | <different> | ||
| 939 | </data> | ||
| 940 | </service> | ||
| 941 | </report> | ||
| 942 | |||
| 943 | Let's have a closer look at it. | ||
| 944 | |||
| 945 | The C<report> tag is a root element. Each of its children is a select. | ||
| 946 | The example above has 2 selects: I<customer> and I<service>. | ||
| 947 | Each select element has 3 children: | ||
| 948 | |||
| 949 | =over 4 | ||
| 950 | |||
| 951 | =item statement | ||
| 952 | |||
| 953 | Contains a full text of a select, which returned given rows. | ||
| 954 | |||
| 955 | =item header | ||
| 956 | |||
| 957 | Contains all columns' names returned by the select | ||
| 958 | |||
| 959 | =item data | ||
| 960 | |||
| 961 | Contains all rows (with all columns) returned by the select. | ||
| 962 | |||
| 963 | =back | ||
| 964 | |||
| 965 | Direct children on I<data> element are: | ||
| 966 | |||
| 967 | =over 4 | ||
| 968 | |||
| 969 | =item equal | ||
| 970 | |||
| 971 | No differences found. | ||
| 972 | |||
| 973 | =item additional | ||
| 974 | |||
| 975 | The row was not present in the I<before> collection but is present in an | ||
| 976 | I<after> collection. | ||
| 977 | |||
| 978 | =item missing | ||
| 979 | |||
| 980 | The row was not present in the I<after> collection but is present in a | ||
| 981 | I<before> collection. | ||
| 982 | |||
| 983 | =item different | ||
| 984 | |||
| 985 | The row is present in the I<after> and I<before> collection. There are some | ||
| 986 | differences found in columns' values. | ||
| 987 | |||
| 988 | =back | ||
| 989 | |||
| 990 | You can read about I<XML> report format in more details later in xxx. | ||
| 991 | |||
| 992 | Now you can get XSLT stylesheets for RTF from source forge and process | ||
| 993 | the generated report. There is some fuzziness around XSLT specification so | ||
| 994 | I can't guarantee that it will work for any XSLT processor. But it worked | ||
| 995 | for me with Saxon. | ||
| 996 | |||
| 997 | After getting RTF stylesheet and installing Saxon, you can run the | ||
| 998 | conversion. On my Windows machine it look like this: | ||
| 999 | |||
| 1000 | java net.sf.saxon.Transform report.xml rld_rtf.xsl > report.rtf | ||
| 1001 | |||
| 1002 | |||
| 1003 | =head1 WORKING MODES | ||
| 1004 | |||
| 1005 | B<lrptxml.pl> can work is 2 modes - csv and diffs. | ||
| 1006 | |||
| 1007 | In csv mode (default one) | ||
| 1008 | B<lrptxmp.pl> will pick all | ||
| 1009 | files with expected extension found is this directory. Since there would | ||
| 1010 | be no comparison information, all rows will be reported as equal. | ||
| 1011 | |||
| 1012 | Second mode is I<diffs> mode, when B<lrptxml.pl> accepts on input a file | ||
| 1013 | produced by B<lcsvdiff.pl> tool ran with B<--all> switch. | ||
| 1014 | In this mode differences are reflected in the output report. | ||
| 1015 | In order to switch to diffs mode, B<--diffs> switch has to be used. | ||
| 1016 | |||
| 1017 | The default mode is reading I<csv> files. | ||
| 1018 | |||
| 1019 | =head1 XML REPORT FORMAT | ||
| 1020 | |||
| 1021 | XML report has to be well formed. Its root element is I<report>. | ||
| 1022 | Its direct children are elements dedicated to results of single selects. | ||
| 1023 | Name of each of this elements is a name of a select. | ||
| 1024 | |||
| 1025 | The general structure of an XML report is given below: | ||
| 1026 | |||
| 1027 | <report> | ||
| 1028 | <select_name1> | ||
| 1029 | <statement>select * from ..... </statement> | ||
| 1030 | <header> | ||
| 1031 | <col1/> | ||
| 1032 | <col2/> | ||
| 1033 | <col3/> | ||
| 1034 | <colN/> | ||
| 1035 | </header> | ||
| 1036 | <data> | ||
| 1037 | <equal> | ||
| 1038 | <col1>value11</col1> | ||
| 1039 | <col2>value12</col2> | ||
| 1040 | <col3>value13</col3> | ||
| 1041 | <colN>value14</colN> | ||
| 1042 | </equal> | ||
| 1043 | <different> | ||
| 1044 | <col1>value21</col1> | ||
| 1045 | <col2>value22</col2> | ||
| 1046 | <col3> | ||
| 1047 | <old_value>old_value23</old_value> | ||
| 1048 | <new_value>new_value23</new_value> | ||
| 1049 | </col3> | ||
| 1050 | <colN>value24</colN> | ||
| 1051 | </different> | ||
| 1052 | <missing> | ||
| 1053 | <col1>value31</col1> | ||
| 1054 | <col2>value32</col2> | ||
| 1055 | <col3>value33</col3> | ||
| 1056 | <colN>value34</colN> | ||
| 1057 | </missing> | ||
| 1058 | <additional> | ||
| 1059 | <col1>value41</col1> | ||
| 1060 | <col2>value42</col2> | ||
| 1061 | <col3>value43</col3> | ||
| 1062 | <colN>value44</colN> | ||
| 1063 | </additional> | ||
| 1064 | </data> | ||
| 1065 | </select_name1> | ||
| 1066 | <select_name2> | ||
| 1067 | ........ | ||
| 1068 | </select_nameN> | ||
| 1069 | </report> | ||
| 1070 | |||
| 1071 | Each select is reported in an element, which name is equal to select name. | ||
| 1072 | It contains the following children: statement, header and data. | ||
| 1073 | |||
| 1074 | =head2 statement | ||
| 1075 | |||
| 1076 | Contains a full text of select which produced reported rows. | ||
| 1077 | |||
| 1078 | =head2 header | ||
| 1079 | |||
| 1080 | Contains elements for all columns in a row. Order of elements is | ||
| 1081 | similar to order of columns in result returned by a select. | ||
| 1082 | |||
| 1083 | =head2 data | ||
| 1084 | |||
| 1085 | Contains actual rows. It may have 4 types of child elements: | ||
| 1086 | |||
| 1087 | =over 4 | ||
| 1088 | |||
| 1089 | =item equal | ||
| 1090 | |||
| 1091 | No differences reported for a given row. Child elements are columns, their | ||
| 1092 | value are values from columns. | ||
| 1093 | |||
| 1094 | =item different | ||
| 1095 | |||
| 1096 | Row existed in I<after> and I<before> collections. Values in some | ||
| 1097 | columns were different. Child elements are columns, their values are values | ||
| 1098 | from columns for all columns except columns where differences were found. | ||
| 1099 | For those columns, column element contains to child elements: I<old_value> and | ||
| 1100 | I<new_value> which contains values from I<before> and I<after> rows. | ||
| 1101 | |||
| 1102 | =item additional | ||
| 1103 | |||
| 1104 | I<before> row does not exist, I<after> row does. | ||
| 1105 | Child elements are columns, their | ||
| 1106 | value are values from columns. | ||
| 1107 | |||
| 1108 | =item missing | ||
| 1109 | |||
| 1110 | I<before> row exists, I<after> row doesn't. | ||
| 1111 | Child elements are columns, their | ||
| 1112 | values are values from columns. | ||
| 1113 | |||
| 1114 | =back | ||
| 1115 | |||
| 1116 | =head1 XSLT STYLESHEET | ||
| 1117 | |||
| 1118 | Currently there is only one stylesheet available, for conversion to RTF | ||
| 1119 | documents. | ||
| 1120 | |||
| 1121 | =head2 RTF converter. | ||
| 1122 | |||
| 1123 | RTF converter create an RTF document. An example of such a document | ||
| 1124 | can be found at xxx. | ||
| 1125 | Section containing results of one | ||
| 1126 | select consists of select statement text and then rows. Rows are not | ||
| 1127 | presented in the tables. Instead each row is one paragraph, with fields | ||
| 1128 | separated by tabs. This is good for presenting multi row selects. | ||
| 1129 | Using tables would make columns very narrow and hardly readable. | ||
| 1130 | Header, containg all columns to be reported is | ||
| 1131 | printed in bold on a gray background. Every second row is shaded, so it's | ||
| 1132 | easier to see which values belongs to which row. | ||
| 1133 | |||
| 1134 | Additional rows (see before-after comparison) are printed using italics, bold | ||
| 1135 | and double underline. | ||
| 1136 | |||
| 1137 | Missing rows are (see before-after comparison) are printed using stroke through | ||
| 1138 | |||
| 1139 | Different rows (see before-after comparison) are presented in standard font. | ||
| 1140 | Only columns that differ are printed in bold, italics and underline. | ||
| 1141 | |||
| 1142 | We can choose to highlight some columns with some colors. It is helpful when | ||
| 1143 | viewing reports with many columns. Highlighting can be used to point readers | ||
| 1144 | attention to most important data. | ||
| 1145 | |||
| 1146 | =head3 FILES | ||
| 1147 | |||
| 1148 | The stylesheet is composed of 3 files: | ||
| 1149 | |||
| 1150 | =over 4 | ||
| 1151 | |||
| 1152 | =item rtf.xsl | ||
| 1153 | |||
| 1154 | Contains the main processing logic. Not to be modified (unless you know | ||
| 1155 | what you are doing) | ||
| 1156 | |||
| 1157 | =item rtf_header.xsl | ||
| 1158 | |||
| 1159 | Some headers and constants related to RTF format. Not to be modified. | ||
| 1160 | |||
| 1161 | =item rldf_rtf.xsl | ||
| 1162 | |||
| 1163 | To be edited by you. Contains details of formating in RTF documents. | ||
| 1164 | I<rldf> stands for I<Report Layout Definition File>. | ||
| 1165 | |||
| 1166 | =back | ||
| 1167 | |||
| 1168 | An example of I<rldf> is given below: | ||
| 1169 | |||
| 1170 | It contains some standard stuff related to XSLT. The only part, which should | ||
| 1171 | be modified by you is contents of I<rld> variable element. You can read | ||
| 1172 | details on I<rld> in next chapter. | ||
| 1173 | |||
| 1174 | =head3 RLD | ||
| 1175 | |||
| 1176 | I<rld> is an XML tree, used to specify details on how are select results | ||
| 1177 | shown in RTF document. It allows to specify, which columns should be on | ||
| 1178 | the report and with what color it should be highlighted. | ||
| 1179 | |||
| 1180 | Its structure is as follows: | ||
| 1181 | |||
| 1182 | <rld> | ||
| 1183 | <select_name1 all="1" > | ||
| 1184 | <col1 color="red" /> | ||
| 1185 | </select_name1> | ||
| 1186 | <select_name2> | ||
| 1187 | <col1 color="blue" /> | ||
| 1188 | <col2 color="yellow" /> | ||
| 1189 | <col3 color="yellow" /> | ||
| 1190 | </select_name2> | ||
| 1191 | </rld> | ||
| 1192 | |||
| 1193 | Element named as a select name defines details for a given select. This element | ||
| 1194 | has one attribute: I<all>. If this attributes value is I<1> than all columns | ||
| 1195 | from the select are shown in RTF document. | ||
| 1196 | |||
| 1197 | Each select element has children elements for columns. Column element may | ||
| 1198 | have one attribute, I<color>, which defines color of column's highlighting. | ||
| 1199 | Possible values are xxxx. | ||
| 1200 | If I<all> attribute is not set to I<1> then only those columns are present | ||
| 1201 | in RTF document, for which column elements are present in I<rld>. | ||
| 1202 | If I<all> attribute is set to I<1> then all columns are present | ||
| 1203 | in RTF document. If column child elements are present, their I<color> | ||
| 1204 | attribute are used for defining color of column highlighting. | ||
| 1205 | |||
| 1206 | =head1 TO DO | ||
| 1207 | |||
| 1208 | More stylesheets from other formats should be available. I am not planning | ||
| 1209 | to do any in the nearest future. | ||
| 1210 | |||
| 1211 | The current RTF stylesheet is poorly documented, and possibly poorly | ||
| 1212 | structured. I am not an XSLT champion. | ||
| 1213 | |||
| 1214 | =head1 SEE ALSO | ||
| 1215 | |||
| 1216 | The project is maintained on Source Forge L<http://lreport.sourceforge.net>. | ||
| 1217 | You can find there links to some helpful documentation like tutorial. | ||
| 1218 | |||
| 1219 | =head1 AUTHORS | ||
| 1220 | |||
| 1221 | Piotr Kaluski E<lt>pkaluski@piotrkaluski.comE<gt> | ||
| 1222 | |||
| 1223 | =head1 COPYRIGHT | ||
| 1224 | |||
| 1225 | Copyright (c) 2004-2006 Piotr Kaluski. Poland. All rights reserved. | ||
| 1226 | |||
| 1227 | You may distribute under the terms of either the GNU General Public License | ||
| 1228 | or the Artistic License, as specified in the Perl README file. | ||
| 1229 | |||
| 1230 | =cut | ||
| 1231 | |||
| 1232 | 1; | ||
| 1233 |