| 2 |
use strict; |
use strict; |
| 3 |
|
|
| 4 |
sub new ($) { |
sub new ($) { |
| 5 |
return bless {}, shift; |
return bless { |
| 6 |
|
global_status => 'conforming', |
| 7 |
|
# or, 'should-error', 'non-conforming', 'uncertain' |
| 8 |
|
subdoc_results => [], |
| 9 |
|
}, shift; |
| 10 |
} # new |
} # new |
| 11 |
|
|
| 12 |
sub output ($;$) { |
sub output ($;$) { |
| 21 |
return $_[0]->{output}; |
return $_[0]->{output}; |
| 22 |
} # output |
} # output |
| 23 |
|
|
| 24 |
|
sub parent_result ($;$) { |
| 25 |
|
if (@_ > 1) { |
| 26 |
|
if (defined $_[1]) { |
| 27 |
|
$_[0]->{parent_result} = $_[1]; |
| 28 |
|
} else { |
| 29 |
|
delete $_[0]->{parent_result}; |
| 30 |
|
} |
| 31 |
|
} |
| 32 |
|
|
| 33 |
|
return $_[0]->{parent_result}; |
| 34 |
|
} # parent_result |
| 35 |
|
|
| 36 |
|
sub layer_applicable ($$) { |
| 37 |
|
my $self = shift; |
| 38 |
|
my $layer = shift; |
| 39 |
|
$self->{layers}->{$layer}->{applicable} = 1; |
| 40 |
|
} # layer_applicable |
| 41 |
|
|
| 42 |
|
sub layer_uncertain ($$) { |
| 43 |
|
my $self = shift; |
| 44 |
|
my $layer = shift; |
| 45 |
|
$self->{layers}->{$layer}->{uncertain} ||= 1; |
| 46 |
|
$self->{layers}->{$layer}->{applicable} = 1; |
| 47 |
|
$self->{global_status} = 'uncertain' |
| 48 |
|
unless $self->{global_status} eq 'non-conforming'; |
| 49 |
|
} # layer_uncertain |
| 50 |
|
|
| 51 |
sub add_error ($%) { |
sub add_error ($%) { |
| 52 |
my ($self, %opt) = @_; |
my ($self, %opt) = @_; |
| 53 |
|
|
| 54 |
my $out = $self->output; |
my $out = $self->output; |
| 55 |
|
$out->has_error (1); |
| 56 |
|
|
| 57 |
my $error_level = $opt{level}; |
my $error_level = $opt{level}; |
| 58 |
if (not defined $error_level) { |
if (not defined $error_level) { |
| 81 |
$error_layer = 'syntax'; ## NOTE: Unknown - an error of the implementation |
$error_layer = 'syntax'; ## NOTE: Unknown - an error of the implementation |
| 82 |
} |
} |
| 83 |
|
|
|
my $error_type_text = $opt{type}; |
|
|
|
|
| 84 |
my $class = qq[level-$error_level layer-$error_layer]; |
my $class = qq[level-$error_level layer-$error_layer]; |
| 85 |
|
|
| 86 |
$out->start_tag ('dt', class => $class); |
## Line & column numbers (prepare values) |
|
my $has_location; |
|
|
|
|
|
## URL |
|
|
|
|
|
if (defined $opt{url}) { |
|
|
$out->url ($opt{url}); |
|
|
$has_location = 1; |
|
|
} |
|
|
|
|
|
## Line & column number |
|
| 87 |
|
|
| 88 |
my $line; |
my $line; |
| 89 |
my $column; |
my $column; |
| 92 |
$line = $opt{node}->get_user_data ('manakai_source_line'); |
$line = $opt{node}->get_user_data ('manakai_source_line'); |
| 93 |
if (defined $line) { |
if (defined $line) { |
| 94 |
$column = $opt{node}->get_user_data ('manakai_source_column'); |
$column = $opt{node}->get_user_data ('manakai_source_column'); |
| 95 |
} else { |
} elsif ($opt{node}->isa ('Message::IF::Node')) { |
| 96 |
if ($opt{node}->node_type == $opt{node}->ATTRIBUTE_NODE) { |
if ($opt{node}->node_type == $opt{node}->ATTRIBUTE_NODE) { |
| 97 |
my $owner = $opt{node}->owner_element; |
my $owner = $opt{node}->owner_element; |
| 98 |
if ($owner) { |
if ($owner) { |
| 117 |
$column = $opt{column}; |
$column = $opt{column}; |
| 118 |
} |
} |
| 119 |
} |
} |
| 120 |
|
$line = $line - 1 || 1 |
| 121 |
|
if defined $line and not (defined $column and $column > 0); |
| 122 |
|
|
| 123 |
|
$out->start_tag ('dt', class => $class, |
| 124 |
|
'data-type' => $opt{type}, |
| 125 |
|
'data-level' => $error_level, |
| 126 |
|
'data-layer' => $error_layer, |
| 127 |
|
($line ? ('data-line' => $line) : ()), |
| 128 |
|
($column ? ('data-column' => $column) : ())); |
| 129 |
|
my $has_location; |
| 130 |
|
|
| 131 |
|
## URL |
| 132 |
|
|
| 133 |
|
if (defined $opt{url}) { |
| 134 |
|
$out->url ($opt{url}); |
| 135 |
|
$has_location = 1; |
| 136 |
|
} |
| 137 |
|
|
| 138 |
|
## Line & column numbers (real output) |
| 139 |
|
|
| 140 |
if (defined $line) { |
if (defined $line) { |
| 141 |
if (defined $column and $column > 0) { |
if (defined $column and $column > 0) { |
| 142 |
$out->xref ('Line ' . $line, target => 'line-' . $line); |
$out->xref ('Line #', text => $line, target => 'line-' . $line); |
| 143 |
$out->text (' column ' . $column); |
$out->text (' '); |
| 144 |
|
$out->nl_text ('column #', text => $column); |
| 145 |
} else { |
} else { |
| 146 |
$line = $line - 1 || 1; |
$out->xref ('Line #', text => $line, target => 'line-' . $line); |
|
$out->xref ('Line ' . $line, target => 'line-' . $line); |
|
| 147 |
} |
} |
| 148 |
$has_location = 1; |
$has_location = 1; |
| 149 |
} |
} |
| 159 |
if (defined $opt{index}) { |
if (defined $opt{index}) { |
| 160 |
if ($opt{index_has_link}) { |
if ($opt{index_has_link}) { |
| 161 |
$out->html (' '); |
$out->html (' '); |
| 162 |
$out->xref ('Index ' . (0+$opt{index}), |
$out->xref ('Index #', text => (0+$opt{index}), |
| 163 |
target => 'index-' . (0+$opt{index})); |
target => 'index-' . (0+$opt{index})); |
| 164 |
} else { |
} else { |
| 165 |
$out->text (' Index ' . (0+$opt{index})); |
$out->html (' '); |
| 166 |
|
$out->nl_text ('Index #', text => (0+$opt{index})); |
| 167 |
} |
} |
| 168 |
$has_location = 1; |
$has_location = 1; |
| 169 |
} |
} |
| 170 |
|
|
| 171 |
if (defined $opt{value}) { |
if (defined $opt{value}) { |
| 172 |
$out->html (' '); |
$out->html (' '); |
| 173 |
$out->code ($opt{value}); |
if (defined $opt{pos_start}) { |
| 174 |
|
$out->start_tag ('code'); |
| 175 |
|
$out->text (substr $opt{value}, 0, $opt{pos_start}); |
| 176 |
|
$out->start_tag ('mark'); |
| 177 |
|
$out->text (substr $opt{value}, $opt{pos_start}, |
| 178 |
|
$opt{pos_end} - $opt{pos_start} + 1); |
| 179 |
|
$out->end_tag ('mark'); |
| 180 |
|
$out->text (substr $opt{value}, $opt{pos_end} + 1) |
| 181 |
|
if $opt{pos_end} < length $opt{value}; |
| 182 |
|
$out->end_tag ('code'); |
| 183 |
|
} elsif ($opt{value_mark_end}) { |
| 184 |
|
$out->start_tag ('code'); |
| 185 |
|
$out->text ($opt{value}); |
| 186 |
|
$out->start_tag ('mark'); |
| 187 |
|
$out->end_tag ('mark'); |
| 188 |
|
$out->end_tag ('code'); |
| 189 |
|
} elsif (defined $opt{value_mark}) { |
| 190 |
|
$out->start_tag ('code'); |
| 191 |
|
for (split /($opt{value_mark})/, $opt{value}) { |
| 192 |
|
if (/$opt{value_mark}/) { |
| 193 |
|
$out->start_tag ('mark'); |
| 194 |
|
$out->text ($_); |
| 195 |
|
$out->end_tag ('mark'); |
| 196 |
|
} else { |
| 197 |
|
$out->text ($_); |
| 198 |
|
} |
| 199 |
|
} |
| 200 |
|
$out->end_tag ('code'); |
| 201 |
|
} else { |
| 202 |
|
$out->code ($opt{value}); |
| 203 |
|
} |
| 204 |
$has_location = 1; |
$has_location = 1; |
| 205 |
} |
} |
| 206 |
|
|
| 215 |
} elsif (defined $opt{input}->{request_uri}) { |
} elsif (defined $opt{input}->{request_uri}) { |
| 216 |
$out->url ($opt{input}->{request_uri}); |
$out->url ($opt{input}->{request_uri}); |
| 217 |
$has_location = 1; |
$has_location = 1; |
| 218 |
} elsif (defined $opt{input}->{uri}) { |
} elsif (defined $opt{input}->url) { |
| 219 |
$out->url ($opt{input}->{uri}); |
$out->url ($opt{input}->url); |
| 220 |
$has_location = 1; |
$has_location = 1; |
| 221 |
} |
} |
| 222 |
} |
} |
| 223 |
|
|
| 224 |
unless ($has_location) { |
unless ($has_location) { |
| 225 |
$out->text ('Unknown location'); |
$out->nl_text ('Unknown location'); |
| 226 |
} |
} |
| 227 |
} |
} |
| 228 |
|
|
| 229 |
$out->start_tag ('dd', class => $class); |
$out->start_tag ('dd', class => $class); |
| 230 |
|
|
| 231 |
## Error level |
## Error level |
| 232 |
|
$out->nl_text ('Error level ' . $error_level); |
| 233 |
|
$out->text (': '); |
| 234 |
|
|
|
if ($error_level eq 'm') { |
|
|
$out->html (qq[<strong><a href="../error-description#level-m"><em class=rfc2119>MUST</em>-level |
|
|
error</a></strong>: ]); |
|
|
} elsif ($error_level eq 's') { |
|
|
$out->html (qq[<strong><a href="../error-description#level-s"><em class=rfc2119>SHOULD</em>-level |
|
|
error</a></strong>: ]); |
|
|
} elsif ($error_level eq 'w') { |
|
|
$out->html (qq[<strong><a href="../error-description#level-w">Warning</a></strong>: ]); |
|
|
} elsif ($error_level eq 'u') { |
|
|
$out->html (qq[<strong><a href="../error-description#level-u">Not |
|
|
supported</a></strong>: ]); |
|
|
} elsif ($error_level eq 'i') { |
|
|
$out->html (qq[<strong><a href="../error-description#level-i">Information</a></strong>: ]); |
|
|
} |
|
|
|
|
| 235 |
## Error message |
## Error message |
| 236 |
|
my $error_type_text = $opt{type}; |
| 237 |
$out->text ($error_type_text); |
$out->nl_text ($error_type_text, node => $opt{node}, text => $opt{text}, |
| 238 |
|
value => $opt{value}, char => $opt{char}, |
| 239 |
## Additional error description |
octets => $opt{octets}); |
|
|
|
|
if (defined $opt{text}) { |
|
|
$out->html (' (<q>'); |
|
|
$out->text ($opt{text}); |
|
|
$out->html ('</q>)'); |
|
|
} |
|
| 240 |
|
|
| 241 |
## Link to a long description |
## Link to a long description |
| 242 |
|
|
| 244 |
$fragment =~ tr/ /-/; |
$fragment =~ tr/ /-/; |
| 245 |
$fragment = $out->encode_url_component ($fragment); |
$fragment = $out->encode_url_component ($fragment); |
| 246 |
$out->text (' ['); |
$out->text (' ['); |
| 247 |
$out->link ('Description', url => '../error-description#' . $fragment, |
$out->start_tag ('a', href => '../error-description#' . $fragment, |
| 248 |
rel => 'help'); |
rel => 'help'); |
| 249 |
|
$out->nl_text ('Description'); |
| 250 |
|
$out->end_tag ('a'); |
| 251 |
$out->text (']'); |
$out->text (']'); |
| 252 |
|
|
| 253 |
|
if ($error_level eq 'm') { |
| 254 |
# my ($type, $cls, $msg) = main::get_text ($opt{type}, $opt{level}); |
$self->{layers}->{$error_layer}->{must}++; |
| 255 |
# $out->html (qq[<dt class="$cls">] . $result->get_error_label ($input, \%opt)); |
$self->{global_status} = 'non-conforming'; |
| 256 |
|
} elsif ($error_level eq 's') { |
| 257 |
$error_layer = 'char' |
$self->{layers}->{$error_layer}->{should}++; |
| 258 |
if $error_layer eq 'charset' or $error_layer eq 'encode'; |
$self->{global_status} = 'should-error' |
| 259 |
if ($error_level eq 's') { |
unless {'non-conforming' => 1, |
| 260 |
$self->{$error_layer}->{should}++; |
uncertain => 1}->{$self->{global_status}}; |
|
$self->{$error_layer}->{score_min} -= 2; |
|
|
$self->{conforming_min} = 0; |
|
| 261 |
} elsif ($error_level eq 'w') { |
} elsif ($error_level eq 'w') { |
| 262 |
$self->{$error_layer}->{warning}++; |
$self->{layers}->{$error_layer}->{warning}++; |
| 263 |
} elsif ($error_level eq 'u') { |
} elsif ($error_level eq 'u') { |
| 264 |
$self->{$error_layer}->{unsupported}++; |
$self->{layers}->{$error_layer}->{uncertain}++; |
| 265 |
$self->{unsupported} = 1; |
$self->{global_status} = 'uncertain' |
| 266 |
|
unless $self->{global_status} eq 'non-conforming'; |
| 267 |
} elsif ($error_level eq 'i') { |
} elsif ($error_level eq 'i') { |
| 268 |
# |
$self->{layers}->{$error_layer}->{info}++; |
|
} else { |
|
|
$self->{$error_layer}->{must}++; |
|
|
$self->{$error_layer}->{score_max} -= 2; |
|
|
$self->{$error_layer}->{score_min} -= 2; |
|
|
$self->{conforming_min} = 0; |
|
|
$self->{conforming_max} = 0; |
|
| 269 |
} |
} |
| 270 |
} # add_error |
} # add_error |
| 271 |
|
|
| 272 |
sub generate_result_section ($) { |
sub generate_result_section ($) { |
| 273 |
my $result = shift; |
my $self = shift; |
| 274 |
|
|
| 275 |
|
my $result = $self; |
| 276 |
|
|
| 277 |
my $out = $result->output; |
my $out = $result->output; |
| 278 |
|
|
| 279 |
$out->start_section (id => 'result-summary', |
$out->start_section (role => 'result'); |
|
title => 'Result'); |
|
| 280 |
|
|
| 281 |
if ($result->{unsupported} and $result->{conforming_max}) { |
my $para_class = { |
| 282 |
$out->html (qq[<p class=uncertain id=result-para>The conformance |
'conforming' => 'result-para no-error', |
| 283 |
checker cannot decide whether the document is conforming or |
'should-error' => 'result-para should-errors', |
| 284 |
not, since the document contains one or more unsupported |
'non-conforming' => 'result-para must-errors', |
| 285 |
features. The document might or might not be conforming.</p>]); |
'uncertain' => 'result-para uncertain', |
| 286 |
} elsif ($result->{conforming_min}) { |
}->{$self->{global_status}}; |
| 287 |
$out->html (qq[<p class=PASS id=result-para>No conformance-error is |
$out->start_tag ('p', class => $para_class); |
| 288 |
found in this document.</p>]); |
$out->nl_text ('Conformance is ' . $self->{global_status}); |
| 289 |
} elsif ($result->{conforming_max}) { |
$out->end_tag ('p'); |
|
$out->html (qq[<p class=SEE-RESULT id=result-para>This document |
|
|
is <strong>likely <em>non</em>-conforming</strong>, but in rare case |
|
|
it might be conforming.</p>]); |
|
|
} else { |
|
|
$out->html (qq[<p class=FAIL id=result-para>This document is |
|
|
<strong><em>non</em>-conforming</strong>.</p>]); |
|
|
} |
|
| 290 |
|
|
| 291 |
$out->html (qq[<table> |
$out->html (qq[<table> |
| 292 |
<colgroup><col><colgroup><col><col><col><colgroup><col> |
<colgroup><col><col><colgroup><col><col><col><col><colgroup><col> |
| 293 |
<thead> |
<thead> |
| 294 |
<tr><th scope=col></th> |
<tr><th scope=col colspan=2>]); |
| 295 |
<th scope=col><a href="../error-description#level-m"><em class=rfc2119>MUST</em>-level |
for ('Error level m', 'Error level s', 'Error level w', |
| 296 |
Errors</a></th> |
'Error level i', 'Score') { |
| 297 |
<th scope=col><a href="../error-description#level-s"><em class=rfc2119>SHOULD</em>-level |
$out->start_tag ('th'); |
| 298 |
Errors</a></th> |
$out->nl_text ($_); |
| 299 |
<th scope=col><a href="../error-description#level-w">Warnings</a></th> |
} |
| 300 |
<th scope=col>Score</th></tr></thead><tbody>]); |
|
| 301 |
|
my $maindoc_status = {must => 0, should => 0, warning => 0, info => 0, |
| 302 |
## TODO: Introduce "N/A" value (e.g. Character layer is not applicable |
uncertain => 0, applicable => 1}; |
| 303 |
## to binary formats) |
my $subdocs_status = {must => 0, should => 0, warning => 0, info => 0, |
| 304 |
|
uncertain => 0, applicable => 1}; |
| 305 |
my $must_error = 0; |
my $global_status = {must => 0, should => 0, warning => 0, info => 0, |
| 306 |
my $should_error = 0; |
uncertain => 0, applicable => 1}; |
| 307 |
my $warning = 0; |
|
| 308 |
my $score_min = 0; |
my $score_unit = 2; |
| 309 |
my $score_max = 0; |
|
| 310 |
my $score_base = 20; |
my @row = ( |
| 311 |
my $score_unit = $score_base / 100; |
sub { |
| 312 |
for ( |
$out->start_tag ('tbody'); |
| 313 |
[Transfer => 'transfer', ''], |
$out->start_tag ('tr'); |
| 314 |
[Character => 'char', ''], |
$out->start_tag ('th', colspan => 7, scope => 'col'); |
| 315 |
[Syntax => 'syntax', '#parse-errors'], |
$out->nl_text ('Main document'); |
| 316 |
[Structure => 'structure', '#document-errors'], |
}, |
| 317 |
) { |
{label => 'Transfer L.', status => $self->{layers}->{transfer}, |
| 318 |
$must_error += ($result->{$_->[1]}->{must} += 0); |
target => 'transfer-errors', score_base => 20, |
| 319 |
$should_error += ($result->{$_->[1]}->{should} += 0); |
parent_status => $maindoc_status}, |
| 320 |
$warning += ($result->{$_->[1]}->{warning} += 0); |
{label => 'Encode L.', status => $self->{layers}->{encode}, |
| 321 |
$score_min += (($result->{$_->[1]}->{score_min} *= $score_unit) += $score_base); |
target => 'parse-errors', score_base => 10, |
| 322 |
$score_max += (($result->{$_->[1]}->{score_max} *= $score_unit) += $score_base); |
parent_status => $maindoc_status}, |
| 323 |
|
{label => 'Char L.', status => $self->{layers}->{charset}, |
| 324 |
my $uncertain = $result->{$_->[1]}->{unsupported} ? '?' : ''; |
target => 'parse-errors', score_base => 10, |
| 325 |
my $label = $_->[0]; |
parent_status => $maindoc_status}, |
| 326 |
if ($result->{$_->[1]}->{must} or |
## TODO: char semantics layer |
| 327 |
$result->{$_->[1]}->{should} or |
{label => 'Syntax L.', status => $self->{layers}->{syntax}, |
| 328 |
$result->{$_->[1]}->{warning} or |
target => 'parse-errors', score_base => 20, |
| 329 |
$result->{$_->[1]}->{unsupported}) { |
parent_status => $maindoc_status}, |
| 330 |
$label = qq[<a href="$_->[2]">$label</a>]; |
{label => 'Structure L.', status => $self->{layers}->{structure}, |
| 331 |
} |
target => 'document-errors', score_base => 20, |
| 332 |
|
parent_status => $maindoc_status}, |
| 333 |
$out->html (qq[<tr class="@{[$uncertain ? 'uncertain' : '']}"><th scope=row>$label</th><td class="@{[$result->{$_->[1]}->{must} ? 'FAIL' : '']}">$result->{$_->[1]}->{must}$uncertain</td><td class="@{[$result->{$_->[1]}->{should} ? 'SEE-RESULT' : '']}">$result->{$_->[1]}->{should}$uncertain</td><td>$result->{$_->[1]}->{warning}$uncertain</td>]); |
{label => 'Semantics L.', status => $self->{layers}->{semantics}, |
| 334 |
if ($uncertain) { |
score_base => 20, |
| 335 |
$out->html (qq[<td class="@{[$result->{$_->[1]}->{must} ? 'FAIL' : $result->{$_->[1]}->{should} ? 'SEE-RESULT' : '']}">−∞..$result->{$_->[1]}->{score_max}]); |
parent_status => $maindoc_status}, |
| 336 |
} elsif ($result->{$_->[1]}->{score_min} != $result->{$_->[1]}->{score_max}) { |
); |
| 337 |
$out->html (qq[<td class="@{[$result->{$_->[1]}->{must} ? 'FAIL' : 'SEE-RESULT']}">$result->{$_->[1]}->{score_min}..$result->{$_->[1]}->{score_max}]); |
|
| 338 |
} else { |
if (@{$self->{subdoc_results}}) { |
| 339 |
$out->html (qq[<td class="@{[$result->{$_->[1]}->{must} ? 'FAIL' : '']}">$result->{$_->[1]}->{score_min}]); |
push @row, {label => 'Subtotal', status => $maindoc_status, |
| 340 |
} |
score_base => 100, |
| 341 |
$out->html (qq[ / 20]); |
parent_status => $global_status, is_total => 1}; |
| 342 |
} |
push @row, sub { |
| 343 |
|
$out->start_tag ('tbody'); |
| 344 |
$score_max += $score_base; |
$out->start_tag ('tr'); |
| 345 |
|
$out->start_tag ('th', colspan => 7, scope => 'col'); |
| 346 |
$out->html (qq[ |
$out->nl_text ('Subdocuments'); |
| 347 |
<tr class=uncertain><th scope=row>Semantics</th><td>0?</td><td>0?</td><td>0?</td><td>−∞..$score_base / 20 |
}; |
| 348 |
</tbody> |
for (@{$self->{subdoc_results}}) { |
| 349 |
<tfoot><tr class=uncertain><th scope=row>Total</th> |
push @row, {label => '#' . $_->{input}->full_subdocument_index, |
| 350 |
<td class="@{[$must_error ? 'FAIL' : '']}">$must_error?</td> |
status => $_, |
| 351 |
<td class="@{[$should_error ? 'SEE-RESULT' : '']}">$should_error?</td> |
target => $_->{input}->id_prefix . 'result-summary', |
| 352 |
<td>$warning?</td> |
score_base => 100, parent_status => $subdocs_status}; |
| 353 |
<td class="@{[$must_error ? 'FAIL' : $should_error ? 'SEE-RESULT' : '']}"><strong>−∞..$score_max</strong> / 100 |
} |
| 354 |
</table> |
push @row, {label => 'Subtotal', status => $subdocs_status, |
| 355 |
|
score_base => 100 * @{$self->{subdoc_results}}, |
| 356 |
|
parent_status => $global_status, is_total => 1}; |
| 357 |
|
} else { |
| 358 |
|
$global_status = $maindoc_status; |
| 359 |
|
} |
| 360 |
|
|
| 361 |
|
push @row, sub { |
| 362 |
|
$out->start_tag ('tfoot'); |
| 363 |
|
}; |
| 364 |
|
push @row, {label => 'Total', status => $global_status, |
| 365 |
|
score_base => 100 * (@{$self->{subdoc_results}} + 1), |
| 366 |
|
parent_status => {}, is_total => 1}; |
| 367 |
|
|
| 368 |
|
for my $x (@row) { |
| 369 |
|
if (ref $x eq 'CODE') { |
| 370 |
|
$x->(); |
| 371 |
|
next; |
| 372 |
|
} |
| 373 |
|
|
| 374 |
|
$x->{parent_status}->{$_} += $x->{status}->{$_} |
| 375 |
|
for qw/must should warning info uncertain/; |
| 376 |
|
|
| 377 |
|
my $row_class = $x->{status}->{uncertain} ? 'uncertain' : ''; |
| 378 |
|
$row_class .= ' total' if $x->{is_total}; |
| 379 |
|
$out->start_tag ('tr', class => $row_class); |
| 380 |
|
my $uncertain = $x->{status}->{uncertain} ? '?' : ''; |
| 381 |
|
|
| 382 |
|
$out->start_tag ('td', class => 'subrow') unless $x->{is_total}; |
| 383 |
|
|
| 384 |
|
## Layer name |
| 385 |
|
$out->start_tag ('th', colspan => $x->{is_total} ? 2 : 1, |
| 386 |
|
scope => 'row'); |
| 387 |
|
if (defined $x->{target} and |
| 388 |
|
($x->{status}->{must} or $x->{status}->{should} or |
| 389 |
|
$x->{status}->{warning} or $x->{status}->{info} or |
| 390 |
|
$x->{status}->{uncertain})) { |
| 391 |
|
$out->xref ($x->{label}, target => $x->{target}); |
| 392 |
|
} else { |
| 393 |
|
$out->nl_text ($x->{label}); |
| 394 |
|
} |
| 395 |
|
|
| 396 |
|
## MUST-level errors |
| 397 |
|
$out->start_tag ('td', class => $x->{status}->{must} ? 'must-errors' : ''); |
| 398 |
|
if ($x->{status}->{applicable}) { |
| 399 |
|
$out->text (($x->{status}->{must} or 0) . $uncertain); |
| 400 |
|
} else { |
| 401 |
|
$out->nl_text ('N/A'); |
| 402 |
|
} |
| 403 |
|
|
| 404 |
|
## SHOULD-level errors |
| 405 |
|
$out->start_tag ('td', |
| 406 |
|
class => $x->{status}->{should} ? 'should-errors' : ''); |
| 407 |
|
if ($x->{status}->{applicable}) { |
| 408 |
|
$out->text (($x->{status}->{should} or 0) . $uncertain); |
| 409 |
|
} else { |
| 410 |
|
$out->nl_text ('N/A'); |
| 411 |
|
} |
| 412 |
|
|
| 413 |
|
## Warnings |
| 414 |
|
$out->start_tag ('td', class => $x->{status}->{warning} ? 'warnings' : ''); |
| 415 |
|
if ($x->{status}->{applicable}) { |
| 416 |
|
$out->text (($x->{status}->{warning} or 0) . $uncertain); |
| 417 |
|
} else { |
| 418 |
|
$out->nl_text ('N/A'); |
| 419 |
|
} |
| 420 |
|
|
| 421 |
|
## Informations |
| 422 |
|
$out->start_tag ('td', class => $x->{status}->{info} ? 'infos' : ''); |
| 423 |
|
if ($x->{status}->{applicable}) { |
| 424 |
|
$out->text (($x->{status}->{info} or 0) . $uncertain); |
| 425 |
|
} else { |
| 426 |
|
$out->nl_text ('N/A'); |
| 427 |
|
} |
| 428 |
|
|
| 429 |
|
## Score |
| 430 |
|
$out->start_tag ('td', |
| 431 |
|
class => $x->{status}->{must} ? 'score must-errors' : |
| 432 |
|
$x->{status}->{should} ? 'score should-errors' : |
| 433 |
|
'score'); |
| 434 |
|
|
| 435 |
|
my $max_score = $x->{score_base}; |
| 436 |
|
$max_score -= $x->{status}->{must} * $score_unit; |
| 437 |
|
my $min_score = $max_score; |
| 438 |
|
$min_score -= $x->{status}->{should} * $score_unit; |
| 439 |
|
|
| 440 |
|
$out->start_tag ('strong'); |
| 441 |
|
if ($x->{status}->{uncertain}) { |
| 442 |
|
$out->html ('−∞ '); # negative inifinity |
| 443 |
|
$out->nl_text ('...'); |
| 444 |
|
$out->html ($max_score < 0 ? |
| 445 |
|
' −' . substr ($max_score, 1) : ' ' . $max_score); |
| 446 |
|
} elsif ($min_score != $max_score) { |
| 447 |
|
$out->html ($min_score < 0 ? |
| 448 |
|
'−' . substr ($min_score, 1) . ' ': $min_score . ' '); |
| 449 |
|
$out->nl_text ('...'); |
| 450 |
|
$out->html ($max_score < 0 ? |
| 451 |
|
' −' . substr ($max_score, 1) : ' ' . $max_score); |
| 452 |
|
} else { |
| 453 |
|
$out->html ($max_score < 0 ? |
| 454 |
|
'−' . substr ($max_score, 1) : $max_score); |
| 455 |
|
} |
| 456 |
|
$out->end_tag ('strong'); |
| 457 |
|
|
| 458 |
|
$out->text (' / ' . $x->{score_base}); |
| 459 |
|
} |
| 460 |
|
|
| 461 |
|
$out->end_tag ('table'); |
| 462 |
|
|
| 463 |
|
my $parent = $self->parent_result; |
| 464 |
|
if ($parent) { |
| 465 |
|
$global_status->{input} = $out->input; |
| 466 |
|
push @{$parent->{subdoc_results}}, $global_status; |
| 467 |
|
} |
| 468 |
|
|
| 469 |
<p><strong>Important</strong>: This conformance checking service |
$out->nl_text ('This checker is work in progress.'); |
|
is <em>under development</em>. The result above might be <em>wrong</em>.</p>]); |
|
| 470 |
$out->end_section; |
$out->end_section; |
| 471 |
} # generate_result_section |
} # generate_result_section |
| 472 |
|
|