--- test/html-webhacc/cc.cgi 2007/09/02 08:40:49 1.18 +++ test/html-webhacc/cc.cgi 2007/09/10 11:51:09 1.19 @@ -83,13 +83,14 @@ ]; - print_http_header_section ($input); + my $result = {}; + print_http_header_section ($input, $result); my $doc; my $el; if ($input->{media_type} eq 'text/html') { - ($doc, $el) = print_syntax_error_html_section ($input); + ($doc, $el) = print_syntax_error_html_section ($input, $result); print_source_string_section (\($input->{s}), $input->{charset}); } elsif ({ 'text/xml' => 1, @@ -99,7 +100,7 @@ 'application/xhtml+xml' => 1, 'application/xml' => 1, }->{$input->{media_type}}) { - ($doc, $el) = print_syntax_error_xml_section ($input); + ($doc, $el) = print_syntax_error_xml_section ($input, $result); print_source_string_section (\($input->{s}), $doc->input_encoding); } else { ## TODO: Change HTTP status code?? @@ -108,14 +109,14 @@ if (defined $doc or defined $el) { print_structure_dump_section ($doc, $el); - my $elements = print_structure_error_section ($doc, $el); + my $elements = print_structure_error_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}}; } - ## TODO: Show result + print_result_section ($result); } else { print STDOUT qq[]; print_result_input_error_section ($input); @@ -141,8 +142,36 @@ exit; -sub print_http_header_section ($) { - my $input = shift; +sub add_error ($$$) { + my ($layer, $err, $result) = @_; + if (defined $err->{level}) { + if ($err->{level} eq 's') { + $result->{$layer}->{should}++; + $result->{$layer}->{score_min} -= 2; + $result->{conforming_min} = 0; + } elsif ($err->{level} eq 'w' or $err->{level} eq 'g') { + $result->{$layer}->{warning}++; + } elsif ($err->{level} eq 'unsupported') { + $result->{$layer}->{unsupported}++; + $result->{unsupported} = 1; + } else { + $result->{$layer}->{must}++; + $result->{$layer}->{score_max} -= 2; + $result->{$layer}->{score_min} -= 2; + $result->{conforming_min} = 0; + $result->{conforming_max} = 0; + } + } else { + $result->{$layer}->{must}++; + $result->{$layer}->{score_max} -= 2; + $result->{$layer}->{score_min} -= 2; + $result->{conforming_min} = 0; + $result->{conforming_max} = 0; + } +} # add_error + +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}}; @@ -175,8 +204,8 @@ print STDOUT qq[]; } # print_http_header_section -sub print_syntax_error_html_section ($) { - my $input = shift; +sub print_syntax_error_html_section ($$) { + my ($input, $result) = @_; require Encode; require Whatpm::HTML; @@ -207,6 +236,8 @@ $type =~ s/\|/%7C/g; $msg .= qq[ [Description]]; print STDOUT qq[
The conformance + checker cannot decide whether the document is conforming or + not, since the document contains one or more unsupported + features.
]; + } elsif ($result->{conforming_min}) { + print STDOUT qq[No conformance-error is + found in this document.
]; + } elsif ($result->{conforming_max}) { + print STDOUT qq[This document + is likely non-conforming, but in rare case + it might be conforming.
]; + } else { + print STDOUT qq[This document is + non-conforming.
]; + } + + print STDOUT qq[MUST-level +Errors | SHOULD-level +Errors | Warnings | Score | ||
---|---|---|---|---|---|
$label | $result->{$_->[1]}->{must}$uncertain | $result->{$_->[1]}->{should}$uncertain | $result->{$_->[1]}->{warning}$uncertain | ]; + if ($uncertain) { + print qq[−∞..$result->{$_->[1]}->{score_max} | ]; + } elsif ($result->{$_->[1]}->{score_min} != $result->{$_->[1]}->{score_max}) { + print qq[$result->{$_->[1]}->{score_min}..$result->{$_->[1]}->{score_max} + $score_base | $result->{$_->[1]}->{score_min} | ]; + } + } + + $score_max += $score_base; + + print STDOUT qq[ +
Semantics | 0? | 0? | 0? | −∞..$score_base | |
Total | $must_error? | $should_error? | $warning? | −∞..$score_max |
Important: This conformance checking service +is under development. The result above might be wrong.
+