--- test/html-webhacc/cc.cgi 2007/11/23 12:08:32 1.29 +++ test/html-webhacc/cc.cgi 2008/02/10 02:42:01 1.33 @@ -89,47 +89,7 @@ ]; my $result = {conforming_min => 1, conforming_max => 1}; - print_http_header_section ($input, $result); - - my $doc; - my $el; - my $manifest; - - if ($input->{media_type} eq 'text/html') { - ($doc, $el) = print_syntax_error_html_section ($input, $result); - print_source_string_section - (\($input->{s}), $input->{charset} || $doc->input_encoding); - } elsif ({ - 'text/xml' => 1, - 'application/atom+xml' => 1, - 'application/rss+xml' => 1, - 'application/svg+xml' => 1, - 'application/xhtml+xml' => 1, - 'application/xml' => 1, - }->{$input->{media_type}}) { - ($doc, $el) = print_syntax_error_xml_section ($input, $result); - print_source_string_section (\($input->{s}), $doc->input_encoding); - } elsif ($input->{media_type} eq 'text/cache-manifest') { -## TODO: MUST be text/cache-manifest - $manifest = print_syntax_error_manifest_section ($input, $result); - print_source_string_section (\($input->{s}), 'utf-8'); - } else { - ## TODO: Change HTTP status code?? - print_result_unknown_type_section ($input, $result); - } - - if (defined $doc or defined $el) { - print_structure_dump_dom_section ($doc, $el); - my $elements = print_structure_error_dom_section ($doc, $el, $result); - print_table_section ($elements->{table}) if @{$elements->{table}}; - print_id_section ($elements->{id}) if keys %{$elements->{id}}; - print_term_section ($elements->{term}) if keys %{$elements->{term}}; - print_class_section ($elements->{class}) if keys %{$elements->{class}}; - } elsif (defined $manifest) { - print_structure_dump_manifest_section ($manifest); - print_structure_error_manifest_section ($manifest, $result); - } - + check_and_print ($input => $result); print_result_section ($result); } else { print STDOUT qq[]; @@ -166,7 +126,7 @@ $result->{conforming_min} = 0; } elsif ($err->{level} eq 'w' or $err->{level} eq 'g') { $result->{$layer}->{warning}++; - } elsif ($err->{level} eq 'unsupported') { + } elsif ($err->{level} eq 'u' or $err->{level} eq 'unsupported') { $result->{$layer}->{unsupported}++; $result->{unsupported} = 1; } else { @@ -185,14 +145,68 @@ } } # add_error +sub check_and_print ($$) { + my ($input, $result) = @_; + $input->{id_prefix} = ''; + #$input->{nested} = 1/0; + + print_http_header_section ($input, $result); + + my $doc; + my $el; + my $manifest; + + if ($input->{media_type} eq 'text/html') { + ($doc, $el) = print_syntax_error_html_section ($input, $result); + print_source_string_section + (\($input->{s}), $input->{charset} || $doc->input_encoding); + } elsif ({ + 'text/xml' => 1, + 'application/atom+xml' => 1, + 'application/rss+xml' => 1, + 'application/svg+xml' => 1, + 'application/xhtml+xml' => 1, + 'application/xml' => 1, + }->{$input->{media_type}}) { + ($doc, $el) = print_syntax_error_xml_section ($input, $result); + print_source_string_section (\($input->{s}), $doc->input_encoding); + } elsif ($input->{media_type} eq 'text/cache-manifest') { +## TODO: MUST be text/cache-manifest + $manifest = print_syntax_error_manifest_section ($input, $result); + print_source_string_section (\($input->{s}), 'utf-8'); + } else { + ## TODO: Change HTTP status code?? + print_result_unknown_type_section ($input, $result); + } + + if (defined $doc or defined $el) { + print_structure_dump_dom_section ($input, $doc, $el); + my $elements = print_structure_error_dom_section + ($input, $doc, $el, $result); + print_table_section ($input, $elements->{table}) if @{$elements->{table}}; + print_listing_section ({ + id => 'identifiers', label => 'IDs', heading => 'Identifiers', + }, $input, $elements->{id}) if keys %{$elements->{id}}; + print_listing_section ({ + id => 'terms', label => 'Terms', heading => 'Terms', + }, $input, $elements->{term}) if keys %{$elements->{term}}; + print_listing_section ({ + id => 'classes', label => 'Classes', heading => 'Classes', + }, $input, $elements->{class}) if keys %{$elements->{class}}; + } elsif (defined $manifest) { + print_structure_dump_manifest_section ($input, $manifest); + print_structure_error_manifest_section ($input, $manifest, $result); + } +} # check_and_print + sub print_http_header_section ($$) { my ($input, $result) = @_; return unless defined $input->{header_status_code} or defined $input->{header_status_text} or @{$input->{header_field}}; - push @nav, ['#source-header' => 'HTTP Header']; - print STDOUT qq[
Note: Due to the limitation of the @@ -226,11 +240,11 @@ require Whatpm::HTML; print STDOUT qq[ -
] . htescape ($attr->[0]) . '
= '; ## ISSUE: case?
+ $r .= qq[] . htescape ($attr->[0]) . '
= '; ## ISSUE: case?
$r .= '' . htescape ($attr->[1]) . '
@{[htescape $id]}
@{[htescape $class]}
Input Error: @{[htescape ($input->{error_status_text})]}