diff options
author | jeff <jeff> | 2010-08-25 16:04:54 +0000 |
---|---|---|
committer | jeff <jeff> | 2010-08-25 16:04:54 +0000 |
commit | 86f48cd03787ab34fffc47c6060027818e6b86b0 (patch) | |
tree | d24e5bc0c2b99112cda05a5b5bda45df70d9a844 | |
parent | aaae2218087232ee04c918f5e4c9ce746e338770 (diff) |
stricter than docs suggest: no 0 values for partIA RT#9721
-rwxr-xr-x | httemplate/search/477partIA_detail.html | 67 | ||||
-rwxr-xr-x | httemplate/search/477partVI_census.html | 2 | ||||
-rw-r--r-- | httemplate/search/elements/search-xml.html | 1 |
3 files changed, 28 insertions, 42 deletions
diff --git a/httemplate/search/477partIA_detail.html b/httemplate/search/477partIA_detail.html index d5184e3f3..e4a59de5f 100755 --- a/httemplate/search/477partIA_detail.html +++ b/httemplate/search/477partIA_detail.html @@ -9,6 +9,7 @@ 'disable_total' => 1, 'header' => [ '', @column_option_name ], 'xml_elements' => [ @xml_elements ], + 'xml_omit_empty' => 1, 'fields' => [ @fields ], ) %> @@ -70,6 +71,9 @@ if ($cgi->param('_type') eq 'xml') { my $query = 'SELECT '. join(' UNION ALL SELECT ',@row_option); my $count_query = 'SELECT '. scalar(@row_option); +my $xml_element = 'OOPS, I was never set'; +my $rowchar = 101; # 'e' -- rows are columns! (pi/2) + my $value = sub { my ($rowref, $column) = (shift, shift); my $row = $rowref->[0]; @@ -78,7 +82,7 @@ my $value = sub { return $row_option_name{$row} || 'no such report option'; } elsif ( $column =~ /^(\d+)$/ ) { my @report_option = ( $row || '', - $column_option[$1 - 2] || '', + $column_option[$column] || '', $technology_option[$tech_code] || '', ); @@ -88,54 +92,35 @@ my $value = sub { my $percentage = sprintf('%.2f', $count ? 100 * $residential / $count : 0); my $return = $count; - $return .= "<BR>$percentage% residential" - unless $cgi->param('_type') eq 'xml'; + + if ($cgi->param('_type') eq 'xml') { + $rowchar++ if $column == 1; + $xml_element = $xml_prefix. chr($rowchar). ($column+1); + $return = '' if $count == 0 and $cgi->param('_type') eq 'xml'; + } else { + $return .= "<BR>$percentage% residential"; + } + return $return; } else { return '<FONT SIZE="+1" COLOR="#ff0000">Bad call to column_value</FONT>'; } }; -my @fields = ( - sub { &{$value}(shift, 'name');}, - sub { &{$value}(shift, 2);}, - sub { &{$value}(shift, 3);}, - sub { &{$value}(shift, 4);}, - sub { &{$value}(shift, 5);}, - sub { &{$value}(shift, 6);}, - sub { &{$value}(shift, 7);}, - sub { &{$value}(shift, 8);}, - sub { &{$value}(shift, 9);}, - ); +my @fields = map { my $ci = $_; sub { &{$value}(shift, $ci); } } + ( 'name', (0 .. $#column_option) ); shift @fields if $cgi->param('_type') eq 'xml'; -my $rowchar = 102; # 'f' -- rows are columns! (pi/2) -my $opentag = 0; -my $xml_element = sub { - my ($rowref, $column) = (shift, shift); - my $row = chr($rowchar); - - if ($column == 8) { - $opentag++; - if ($opentag > 1) { # a new row - $rowchar++; - $opentag = 0; - } - } - - $xml_prefix. $row. $column; - -}; - -my @xml_elements = ( - sub { &{$xml_element}(shift, '1') }, - sub { &{$xml_element}(shift, '2') }, - sub { &{$xml_element}(shift, '3') }, - sub { &{$xml_element}(shift, '4') }, - sub { &{$xml_element}(shift, '5') }, - sub { &{$xml_element}(shift, '6') }, - sub { &{$xml_element}(shift, '7') }, - sub { &{$xml_element}(shift, '8') }, +my @xml_elements = ( # -- columns are rows! (pi/2) + sub { return $xml_element; }, + sub { return $xml_element; }, + sub { return $xml_element; }, + sub { return $xml_element; }, + sub { return $xml_element; }, + sub { return $xml_element; }, + sub { return $xml_element; }, + sub { return $xml_element; }, + sub { return $xml_element; }, ); </%init> diff --git a/httemplate/search/477partVI_census.html b/httemplate/search/477partVI_census.html index db572bcde..5f3039d1a 100755 --- a/httemplate/search/477partVI_census.html +++ b/httemplate/search/477partVI_census.html @@ -33,7 +33,7 @@ 'upload', 'download', 'technology_code', - sub { '' }, # doesn't really work + sub { $cgi->param('_type') eq 'xml' ? '0' : '' }, # doesn't really work 'quantity', sub { my $row = shift; sprintf "%.2f", $row->residential }, ], diff --git a/httemplate/search/elements/search-xml.html b/httemplate/search/elements/search-xml.html index 9f5e9b6c1..50b191610 100644 --- a/httemplate/search/elements/search-xml.html +++ b/httemplate/search/elements/search-xml.html @@ -14,6 +14,7 @@ % } else { % $value = $row->$field(); % } +% next unless ($value || !$opt{xml_omit_empty}); % <% &{$beginfield}($row, $i) %><% $value |h %><% &{$endfield}($row, $i) %> % |