| 1 | package CGI::OptimalQuery::XML; | ||
| 2 | |||
| 3 | 1 | ▶ | use strict; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 4 | 1 | ▶ | use warnings; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 5 | 1 | ▶ | no warnings qw( uninitialized ); |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 6 | 1 | ▶ | use base 'CGI::OptimalQuery::Base'; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 7 | use CGI(); | ||
| 8 | |||
| 9 | sub output { | ||
| 10 | my $o = shift; | ||
| 11 | |||
| 12 | my $title = $o->{schema}->{title}; | ||
| 13 | $title =~ s/\W//g; | ||
| 14 | my @t = localtime; | ||
| 15 | $title .= '_'.($t[5] + 1900).($t[4] + 1).$t[3].$t[2].$t[1]; | ||
| 16 | |||
| 17 | $$o{output_handler}->($$o{httpHeader}->(-type => 'text/xml', -attachment => "$title.xml"). | ||
| 18 | "<?xml version=\"1.0\"?>\n<OptimalQuery>\n"); | ||
| 19 | |||
| 20 | my @userselcols = @{ $o->get_usersel_cols }; | ||
| 21 | |||
| 22 | # print data | ||
| 23 | while (my $rec = $o->fetch()) { | ||
| 24 | my $buf = "<rec id=\"$$rec{U_ID}\">\n"; | ||
| 25 | foreach my $col (@userselcols) { | ||
| 26 | $buf .= " <$col>".$o->escape_html($o->get_val($col))."</$col>\n"; | ||
| 27 | } | ||
| 28 | $buf .= "</rec>\n"; | ||
| 29 | $$o{output_handler}->($buf); | ||
| 30 | } | ||
| 31 | $$o{output_handler}->("</OptimalQuery>"); | ||
| 32 | $o->finish(); | ||
| 33 | return undef; | ||
| 34 | } | ||
| 35 | |||
| 36 | |||
| 37 | 1; | ||