| 89 |
]; |
]; |
| 90 |
|
|
| 91 |
my $result = {conforming_min => 1, conforming_max => 1}; |
my $result = {conforming_min => 1, conforming_max => 1}; |
| 92 |
print_http_header_section ($input, $result); |
check_and_print ($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); |
|
|
} |
|
|
|
|
| 93 |
print_result_section ($result); |
print_result_section ($result); |
| 94 |
} else { |
} else { |
| 95 |
print STDOUT qq[</dl></div>]; |
print STDOUT qq[</dl></div>]; |
| 126 |
$result->{conforming_min} = 0; |
$result->{conforming_min} = 0; |
| 127 |
} elsif ($err->{level} eq 'w' or $err->{level} eq 'g') { |
} elsif ($err->{level} eq 'w' or $err->{level} eq 'g') { |
| 128 |
$result->{$layer}->{warning}++; |
$result->{$layer}->{warning}++; |
| 129 |
} elsif ($err->{level} eq 'unsupported') { |
} elsif ($err->{level} eq 'u' or $err->{level} eq 'unsupported') { |
| 130 |
$result->{$layer}->{unsupported}++; |
$result->{$layer}->{unsupported}++; |
| 131 |
$result->{unsupported} = 1; |
$result->{unsupported} = 1; |
| 132 |
} else { |
} else { |
| 145 |
} |
} |
| 146 |
} # add_error |
} # add_error |
| 147 |
|
|
| 148 |
|
sub check_and_print ($$) { |
| 149 |
|
my ($input, $result) = @_; |
| 150 |
|
$input->{id_prefix} = ''; |
| 151 |
|
#$input->{nested} = 1/0; |
| 152 |
|
|
| 153 |
|
print_http_header_section ($input, $result); |
| 154 |
|
|
| 155 |
|
my $doc; |
| 156 |
|
my $el; |
| 157 |
|
my $manifest; |
| 158 |
|
my @subdoc; |
| 159 |
|
|
| 160 |
|
if ($input->{media_type} eq 'text/html') { |
| 161 |
|
($doc, $el) = print_syntax_error_html_section ($input, $result); |
| 162 |
|
print_source_string_section |
| 163 |
|
(\($input->{s}), $input->{charset} || $doc->input_encoding); |
| 164 |
|
} elsif ({ |
| 165 |
|
'text/xml' => 1, |
| 166 |
|
'application/atom+xml' => 1, |
| 167 |
|
'application/rss+xml' => 1, |
| 168 |
|
'application/svg+xml' => 1, |
| 169 |
|
'application/xhtml+xml' => 1, |
| 170 |
|
'application/xml' => 1, |
| 171 |
|
}->{$input->{media_type}}) { |
| 172 |
|
($doc, $el) = print_syntax_error_xml_section ($input, $result); |
| 173 |
|
print_source_string_section (\($input->{s}), $doc->input_encoding); |
| 174 |
|
} elsif ($input->{media_type} eq 'text/cache-manifest') { |
| 175 |
|
## TODO: MUST be text/cache-manifest |
| 176 |
|
$manifest = print_syntax_error_manifest_section ($input, $result); |
| 177 |
|
print_source_string_section (\($input->{s}), 'utf-8'); |
| 178 |
|
} else { |
| 179 |
|
## TODO: Change HTTP status code?? |
| 180 |
|
print_result_unknown_type_section ($input, $result); |
| 181 |
|
} |
| 182 |
|
|
| 183 |
|
if (defined $doc or defined $el) { |
| 184 |
|
$doc->document_uri ($input->{uri}); |
| 185 |
|
$doc->manakai_entity_base_uri ($input->{base_uri}); |
| 186 |
|
print_structure_dump_dom_section ($input, $doc, $el); |
| 187 |
|
my $elements = print_structure_error_dom_section |
| 188 |
|
($input, $doc, $el, $result, sub { |
| 189 |
|
push @subdoc, shift; |
| 190 |
|
}); |
| 191 |
|
print_table_section ($input, $elements->{table}) if @{$elements->{table}}; |
| 192 |
|
print_listing_section ({ |
| 193 |
|
id => 'identifiers', label => 'IDs', heading => 'Identifiers', |
| 194 |
|
}, $input, $elements->{id}) if keys %{$elements->{id}}; |
| 195 |
|
print_listing_section ({ |
| 196 |
|
id => 'terms', label => 'Terms', heading => 'Terms', |
| 197 |
|
}, $input, $elements->{term}) if keys %{$elements->{term}}; |
| 198 |
|
print_listing_section ({ |
| 199 |
|
id => 'classes', label => 'Classes', heading => 'Classes', |
| 200 |
|
}, $input, $elements->{class}) if keys %{$elements->{class}}; |
| 201 |
|
} elsif (defined $manifest) { |
| 202 |
|
print_structure_dump_manifest_section ($input, $manifest); |
| 203 |
|
print_structure_error_manifest_section ($input, $manifest, $result); |
| 204 |
|
} |
| 205 |
|
|
| 206 |
|
my $id_prefix = 0; |
| 207 |
|
for my $subinput (@subdoc) { |
| 208 |
|
$subinput->{id_prefix} = 'subdoc-' . ++$id_prefix; |
| 209 |
|
$subinput->{nested} = 1; |
| 210 |
|
$subinput->{base_uri} = $subinput->{container_node}->base_uri |
| 211 |
|
unless defined $subinput->{base_uri}; |
| 212 |
|
my $ebaseuri = htescape ($subinput->{base_uri}); |
| 213 |
|
push @nav, ['#' . $subinput->{id_prefix} => 'Sub #' . $id_prefix]; |
| 214 |
|
print STDOUT qq[<div id="$subinput->{id_prefix}" class=section> |
| 215 |
|
<h2>Subdocument #$id_prefix</h2> |
| 216 |
|
|
| 217 |
|
<dl> |
| 218 |
|
<dt>Internet Media Type</dt> |
| 219 |
|
<dd><code class="MIME" lang="en">@{[htescape $subinput->{media_type}]}</code> |
| 220 |
|
<dt>Container Node</dt> |
| 221 |
|
<dd>@{[get_node_link ($input, $subinput->{container_node})]}</dd> |
| 222 |
|
<dt>Base <abbr title="Uniform Resource Identifiers">URI</abbr></dt> |
| 223 |
|
<dd><code class=URI><<a href="$ebaseuri">$ebaseuri</a>></code></dd> |
| 224 |
|
</dl>]; |
| 225 |
|
|
| 226 |
|
check_and_print ($subinput => $result); |
| 227 |
|
|
| 228 |
|
print STDOUT qq[</div>]; |
| 229 |
|
} |
| 230 |
|
} # check_and_print |
| 231 |
|
|
| 232 |
sub print_http_header_section ($$) { |
sub print_http_header_section ($$) { |
| 233 |
my ($input, $result) = @_; |
my ($input, $result) = @_; |
| 234 |
return unless defined $input->{header_status_code} or |
return unless defined $input->{header_status_code} or |
| 235 |
defined $input->{header_status_text} or |
defined $input->{header_status_text} or |
| 236 |
@{$input->{header_field}}; |
@{$input->{header_field} or []}; |
| 237 |
|
|
| 238 |
push @nav, ['#source-header' => 'HTTP Header']; |
push @nav, ['#source-header' => 'HTTP Header'] unless $input->{nested}; |
| 239 |
print STDOUT qq[<div id="source-header" class="section"> |
print STDOUT qq[<div id="$input->{id_prefix}source-header" class="section"> |
| 240 |
<h2>HTTP Header</h2> |
<h2>HTTP Header</h2> |
| 241 |
|
|
| 242 |
<p><strong>Note</strong>: Due to the limitation of the |
<p><strong>Note</strong>: Due to the limitation of the |
| 270 |
require Whatpm::HTML; |
require Whatpm::HTML; |
| 271 |
|
|
| 272 |
print STDOUT qq[ |
print STDOUT qq[ |
| 273 |
<div id="parse-errors" class="section"> |
<div id="$input->{id_prefix}parse-errors" class="section"> |
| 274 |
<h2>Parse Errors</h2> |
<h2>Parse Errors</h2> |
| 275 |
|
|
| 276 |
<dl>]; |
<dl>]; |
| 277 |
push @nav, ['#parse-errors' => 'Parse Error']; |
push @nav, ['#parse-errors' => 'Parse Error'] unless $input->{nested}; |
| 278 |
|
|
| 279 |
my $onerror = sub { |
my $onerror = sub { |
| 280 |
my (%opt) = @_; |
my (%opt) = @_; |
| 328 |
require Message::DOM::XMLParserTemp; |
require Message::DOM::XMLParserTemp; |
| 329 |
|
|
| 330 |
print STDOUT qq[ |
print STDOUT qq[ |
| 331 |
<div id="parse-errors" class="section"> |
<div id="$input->{id_prefix}parse-errors" class="section"> |
| 332 |
<h2>Parse Errors</h2> |
<h2>Parse Errors</h2> |
| 333 |
|
|
| 334 |
<dl>]; |
<dl>]; |
| 335 |
push @nav, ['#parse-errors' => 'Parse Error']; |
push @nav, ['#parse-errors' => 'Parse Error'] unless $input->{prefix}; |
| 336 |
|
|
| 337 |
my $onerror = sub { |
my $onerror = sub { |
| 338 |
my $err = shift; |
my $err = shift; |
| 370 |
require Whatpm::CacheManifest; |
require Whatpm::CacheManifest; |
| 371 |
|
|
| 372 |
print STDOUT qq[ |
print STDOUT qq[ |
| 373 |
<div id="parse-errors" class="section"> |
<div id="$input->{id_prefix}parse-errors" class="section"> |
| 374 |
<h2>Parse Errors</h2> |
<h2>Parse Errors</h2> |
| 375 |
|
|
| 376 |
<dl>]; |
<dl>]; |
| 377 |
push @nav, ['#parse-errors' => 'Parse Error']; |
push @nav, ['#parse-errors' => 'Parse Error'] unless $input->{nested}; |
| 378 |
|
|
| 379 |
my $onerror = sub { |
my $onerror = sub { |
| 380 |
my (%opt) = @_; |
my (%opt) = @_; |
| 381 |
my ($type, $cls, $msg) = get_text ($opt{type}, $opt{level}); |
my ($type, $cls, $msg) = get_text ($opt{type}, $opt{level}); |
| 382 |
print STDOUT qq[<dt class="$cls">], get_error_label (\%opt), qq[</dt>]; |
print STDOUT qq[<dt class="$cls">], get_error_label ($input, \%opt), |
| 383 |
|
qq[</dt>]; |
| 384 |
$type =~ tr/ /-/; |
$type =~ tr/ /-/; |
| 385 |
$type =~ s/\|/%7C/g; |
$type =~ s/\|/%7C/g; |
| 386 |
$msg .= qq[ [<a href="../error-description#@{[htescape ($type)]}">Description</a>]]; |
$msg .= qq[ [<a href="../error-description#@{[htescape ($type)]}">Description</a>]]; |
| 407 |
|
|
| 408 |
my $s = \($enc->decode (${$_[0]})); |
my $s = \($enc->decode (${$_[0]})); |
| 409 |
my $i = 1; |
my $i = 1; |
| 410 |
push @nav, ['#source-string' => 'Source']; |
push @nav, ['#source-string' => 'Source'] unless $input->{nested}; |
| 411 |
print STDOUT qq[<div id="source-string" class="section"> |
print STDOUT qq[<div id="$input->{id_prefix}source-string" class="section"> |
| 412 |
<h2>Document Source</h2> |
<h2>Document Source</h2> |
| 413 |
<ol lang="">\n]; |
<ol lang="">\n]; |
| 414 |
if (length $$s) { |
if (length $$s) { |
| 415 |
while ($$s =~ /\G([^\x0A]*?)\x0D?\x0A/gc) { |
while ($$s =~ /\G([^\x0A]*?)\x0D?\x0A/gc) { |
| 416 |
print STDOUT qq[<li id="line-$i">], htescape $1, "</li>\n"; |
print STDOUT qq[<li id="$input->{id_prefix}line-$i">], htescape $1, |
| 417 |
|
"</li>\n"; |
| 418 |
$i++; |
$i++; |
| 419 |
} |
} |
| 420 |
if ($$s =~ /\G([^\x0A]+)/gc) { |
if ($$s =~ /\G([^\x0A]+)/gc) { |
| 421 |
print STDOUT qq[<li id="line-$i">], htescape $1, "</li>\n"; |
print STDOUT qq[<li id="$input->{id_prefix}line-$i">], htescape $1, |
| 422 |
|
"</li>\n"; |
| 423 |
} |
} |
| 424 |
} else { |
} else { |
| 425 |
print STDOUT q[<li id="line-1"></li>]; |
print STDOUT q[<li id="$input->{id_prefix}line-1"></li>]; |
| 426 |
} |
} |
| 427 |
print STDOUT "</ol></div>"; |
print STDOUT "</ol></div>"; |
| 428 |
} # print_input_string_section |
} # print_input_string_section |
| 439 |
next; |
next; |
| 440 |
} |
} |
| 441 |
|
|
| 442 |
my $node_id = 'node-'.refaddr $child; |
my $node_id = $input->{id_prefix} . 'node-'.refaddr $child; |
| 443 |
my $nt = $child->node_type; |
my $nt = $child->node_type; |
| 444 |
if ($nt == $child->ELEMENT_NODE) { |
if ($nt == $child->ELEMENT_NODE) { |
| 445 |
my $child_nsuri = $child->namespace_uri; |
my $child_nsuri = $child->namespace_uri; |
| 450 |
$r .= '<ul class="attributes">'; |
$r .= '<ul class="attributes">'; |
| 451 |
for my $attr (sort {$a->[0] cmp $b->[0]} map { [$_->name, $_->value, $_->namespace_uri, 'node-'.refaddr $_] } |
for my $attr (sort {$a->[0] cmp $b->[0]} map { [$_->name, $_->value, $_->namespace_uri, 'node-'.refaddr $_] } |
| 452 |
@{$child->attributes}) { |
@{$child->attributes}) { |
| 453 |
$r .= qq[<li id="$attr->[3]" class="tree-attribute"><code title="@{[defined $attr->[2] ? htescape ($attr->[2]) : '']}">] . htescape ($attr->[0]) . '</code> = '; ## ISSUE: case? |
$r .= qq[<li id="$input->{id_prefix}$attr->[3]" class="tree-attribute"><code title="@{[defined $attr->[2] ? htescape ($attr->[2]) : '']}">] . htescape ($attr->[0]) . '</code> = '; ## ISSUE: case? |
| 454 |
$r .= '<q>' . htescape ($attr->[1]) . '</q></li>'; ## TODO: children |
$r .= '<q>' . htescape ($attr->[1]) . '</q></li>'; ## TODO: children |
| 455 |
} |
} |
| 456 |
$r .= '</ul>'; |
$r .= '</ul>'; |
| 519 |
print STDOUT $r; |
print STDOUT $r; |
| 520 |
} # print_document_tree |
} # print_document_tree |
| 521 |
|
|
| 522 |
sub print_structure_dump_dom_section ($$) { |
sub print_structure_dump_dom_section ($$$) { |
| 523 |
my ($doc, $el) = @_; |
my ($input, $doc, $el) = @_; |
| 524 |
|
|
| 525 |
print STDOUT qq[ |
print STDOUT qq[ |
| 526 |
<div id="document-tree" class="section"> |
<div id="$input->{id_prefix}document-tree" class="section"> |
| 527 |
<h2>Document Tree</h2> |
<h2>Document Tree</h2> |
| 528 |
]; |
]; |
| 529 |
push @nav, ['#document-tree' => 'Tree']; |
push @nav, ['#document-tree' => 'Tree'] unless $input->{nested}; |
| 530 |
|
|
| 531 |
print_document_tree ($el || $doc); |
print_document_tree ($el || $doc); |
| 532 |
|
|
| 533 |
print STDOUT qq[</div>]; |
print STDOUT qq[</div>]; |
| 534 |
} # print_structure_dump_dom_section |
} # print_structure_dump_dom_section |
| 535 |
|
|
| 536 |
sub print_structure_dump_manifest_section ($) { |
sub print_structure_dump_manifest_section ($$) { |
| 537 |
my $manifest = shift; |
my ($input, $manifest) = @_; |
| 538 |
|
|
| 539 |
print STDOUT qq[ |
print STDOUT qq[ |
| 540 |
<div id="dump-manifest" class="section"> |
<div id="$input->{id_prefix}dump-manifest" class="section"> |
| 541 |
<h2>Cache Manifest</h2> |
<h2>Cache Manifest</h2> |
| 542 |
]; |
]; |
| 543 |
push @nav, ['#dump-manifest' => 'Caceh Manifest']; |
push @nav, ['#dump-manifest' => 'Caceh Manifest'] unless $input->{nested}; |
| 544 |
|
|
| 545 |
print STDOUT qq[<dl><dt>Explicit entries</dt>]; |
print STDOUT qq[<dl><dt>Explicit entries</dt>]; |
| 546 |
for my $uri (@{$manifest->[0]}) { |
for my $uri (@{$manifest->[0]}) { |
| 567 |
print STDOUT qq[</dl></div>]; |
print STDOUT qq[</dl></div>]; |
| 568 |
} # print_structure_dump_manifest_section |
} # print_structure_dump_manifest_section |
| 569 |
|
|
| 570 |
sub print_structure_error_dom_section ($$$) { |
sub print_structure_error_dom_section ($$$$$) { |
| 571 |
my ($doc, $el, $result) = @_; |
my ($input, $doc, $el, $result, $onsubdoc) = @_; |
| 572 |
|
|
| 573 |
print STDOUT qq[<div id="document-errors" class="section"> |
print STDOUT qq[<div id="$input->{id_prefix}document-errors" class="section"> |
| 574 |
<h2>Document Errors</h2> |
<h2>Document Errors</h2> |
| 575 |
|
|
| 576 |
<dl>]; |
<dl>]; |
| 577 |
push @nav, ['#document-errors' => 'Document Error']; |
push @nav, ['#document-errors' => 'Document Error'] unless $input->{nested}; |
| 578 |
|
|
| 579 |
require Whatpm::ContentChecker; |
require Whatpm::ContentChecker; |
| 580 |
my $onerror = sub { |
my $onerror = sub { |
| 583 |
$type =~ tr/ /-/; |
$type =~ tr/ /-/; |
| 584 |
$type =~ s/\|/%7C/g; |
$type =~ s/\|/%7C/g; |
| 585 |
$msg .= qq[ [<a href="../error-description#@{[htescape ($type)]}">Description</a>]]; |
$msg .= qq[ [<a href="../error-description#@{[htescape ($type)]}">Description</a>]]; |
| 586 |
print STDOUT qq[<dt class="$cls">] . get_error_label (\%opt) . |
print STDOUT qq[<dt class="$cls">] . get_error_label ($input, \%opt) . |
| 587 |
qq[</dt>\n<dd class="$cls">], get_error_level_label (\%opt); |
qq[</dt>\n<dd class="$cls">], get_error_level_label (\%opt); |
| 588 |
print STDOUT $msg, "</dd>\n"; |
print STDOUT $msg, "</dd>\n"; |
| 589 |
add_error ('structure', \%opt => $result); |
add_error ('structure', \%opt => $result); |
| 592 |
my $elements; |
my $elements; |
| 593 |
my $time1 = time; |
my $time1 = time; |
| 594 |
if ($el) { |
if ($el) { |
| 595 |
$elements = Whatpm::ContentChecker->check_element ($el, $onerror); |
$elements = Whatpm::ContentChecker->check_element |
| 596 |
|
($el, $onerror, $onsubdoc); |
| 597 |
} else { |
} else { |
| 598 |
$elements = Whatpm::ContentChecker->check_document ($doc, $onerror); |
$elements = Whatpm::ContentChecker->check_document |
| 599 |
|
($doc, $onerror, $onsubdoc); |
| 600 |
} |
} |
| 601 |
$time{check} = time - $time1; |
$time{check} = time - $time1; |
| 602 |
|
|
| 606 |
} # print_structure_error_dom_section |
} # print_structure_error_dom_section |
| 607 |
|
|
| 608 |
sub print_structure_error_manifest_section ($$$) { |
sub print_structure_error_manifest_section ($$$) { |
| 609 |
my ($manifest, $result) = @_; |
my ($input, $manifest, $result) = @_; |
| 610 |
|
|
| 611 |
print STDOUT qq[<div id="document-errors" class="section"> |
print STDOUT qq[<div id="$input->{id_prefix}document-errors" class="section"> |
| 612 |
<h2>Document Errors</h2> |
<h2>Document Errors</h2> |
| 613 |
|
|
| 614 |
<dl>]; |
<dl>]; |
| 615 |
push @nav, ['#document-errors' => 'Document Error']; |
push @nav, ['#document-errors' => 'Document Error'] unless $input->{nested}; |
| 616 |
|
|
| 617 |
require Whatpm::CacheManifest; |
require Whatpm::CacheManifest; |
| 618 |
Whatpm::CacheManifest->check_manifest ($manifest, sub { |
Whatpm::CacheManifest->check_manifest ($manifest, sub { |
| 621 |
$type =~ tr/ /-/; |
$type =~ tr/ /-/; |
| 622 |
$type =~ s/\|/%7C/g; |
$type =~ s/\|/%7C/g; |
| 623 |
$msg .= qq[ [<a href="../error-description#@{[htescape ($type)]}">Description</a>]]; |
$msg .= qq[ [<a href="../error-description#@{[htescape ($type)]}">Description</a>]]; |
| 624 |
print STDOUT qq[<dt class="$cls">] . get_error_label (\%opt) . |
print STDOUT qq[<dt class="$cls">] . get_error_label ($input, \%opt) . |
| 625 |
qq[</dt>\n<dd class="$cls">], $msg, "</dd>\n"; |
qq[</dt>\n<dd class="$cls">], $msg, "</dd>\n"; |
| 626 |
add_error ('structure', \%opt => $result); |
add_error ('structure', \%opt => $result); |
| 627 |
}); |
}); |
| 629 |
print STDOUT qq[</div>]; |
print STDOUT qq[</div>]; |
| 630 |
} # print_structure_error_manifest_section |
} # print_structure_error_manifest_section |
| 631 |
|
|
| 632 |
sub print_table_section ($) { |
sub print_table_section ($$) { |
| 633 |
my $tables = shift; |
my ($input, $tables) = @_; |
| 634 |
|
|
| 635 |
push @nav, ['#tables' => 'Tables']; |
push @nav, ['#tables' => 'Tables'] unless $input->{nested}; |
| 636 |
print STDOUT qq[ |
print STDOUT qq[ |
| 637 |
<div id="tables" class="section"> |
<div id="$input->{id_prefix}tables" class="section"> |
| 638 |
<h2>Tables</h2> |
<h2>Tables</h2> |
| 639 |
|
|
| 640 |
<!--[if IE]><script type="text/javascript" src="../excanvas.js"></script><![endif]--> |
<!--[if IE]><script type="text/javascript" src="../excanvas.js"></script><![endif]--> |
| 649 |
my $i = 0; |
my $i = 0; |
| 650 |
for my $table_el (@$tables) { |
for my $table_el (@$tables) { |
| 651 |
$i++; |
$i++; |
| 652 |
print STDOUT qq[<div class="section" id="table-$i"><h3>] . |
print STDOUT qq[<div class="section" id="$input->{id_prefix}table-$i"><h3>] . |
| 653 |
get_node_link ($table_el) . q[</h3>]; |
get_node_link ($input, $table_el) . q[</h3>]; |
| 654 |
|
|
| 655 |
## TODO: Make |ContentChecker| return |form_table| result |
## TODO: Make |ContentChecker| return |form_table| result |
| 656 |
## so that this script don't have to run the algorithm twice. |
## so that this script don't have to run the algorithm twice. |
| 682 |
|
|
| 683 |
print STDOUT '</div><script type="text/javascript">tableToCanvas ('; |
print STDOUT '</div><script type="text/javascript">tableToCanvas ('; |
| 684 |
print STDOUT JSON::objToJson ($table); |
print STDOUT JSON::objToJson ($table); |
| 685 |
print STDOUT qq[, document.getElementById ('table-$i'));</script>]; |
print STDOUT qq[, document.getElementById ('$input->{id_prefix}table-$i')]; |
| 686 |
|
print STDOUT qq[, '$input->{id_prefix}');</script>]; |
| 687 |
} |
} |
| 688 |
|
|
| 689 |
print STDOUT qq[</div>]; |
print STDOUT qq[</div>]; |
| 690 |
} # print_table_section |
} # print_table_section |
| 691 |
|
|
| 692 |
sub print_id_section ($) { |
sub print_listing_section ($$$) { |
| 693 |
my $ids = shift; |
my ($opt, $input, $ids) = @_; |
| 694 |
|
|
| 695 |
push @nav, ['#identifiers' => 'IDs']; |
push @nav, ['#' . $opt->{id} => $opt->{label}] unless $input->{nested}; |
| 696 |
print STDOUT qq[ |
print STDOUT qq[ |
| 697 |
<div id="identifiers" class="section"> |
<div id="$input->{id_prefix}$opt->{id}" class="section"> |
| 698 |
<h2>Identifiers</h2> |
<h2>$opt->{heading}</h2> |
| 699 |
|
|
| 700 |
<dl> |
<dl> |
| 701 |
]; |
]; |
| 702 |
for my $id (sort {$a cmp $b} keys %$ids) { |
for my $id (sort {$a cmp $b} keys %$ids) { |
| 703 |
print STDOUT qq[<dt><code>@{[htescape $id]}</code></dt>]; |
print STDOUT qq[<dt><code>@{[htescape $id]}</code></dt>]; |
| 704 |
for (@{$ids->{$id}}) { |
for (@{$ids->{$id}}) { |
| 705 |
print STDOUT qq[<dd>].get_node_link ($_).qq[</dd>]; |
print STDOUT qq[<dd>].get_node_link ($input, $_).qq[</dd>]; |
| 706 |
} |
} |
| 707 |
} |
} |
| 708 |
print STDOUT qq[</dl></div>]; |
print STDOUT qq[</dl></div>]; |
| 709 |
} # print_id_section |
} # print_listing_section |
|
|
|
|
sub print_term_section ($) { |
|
|
my $terms = shift; |
|
|
|
|
|
push @nav, ['#terms' => 'Terms']; |
|
|
print STDOUT qq[ |
|
|
<div id="terms" class="section"> |
|
|
<h2>Terms</h2> |
|
|
|
|
|
<dl> |
|
|
]; |
|
|
for my $term (sort {$a cmp $b} keys %$terms) { |
|
|
print STDOUT qq[<dt>@{[htescape $term]}</dt>]; |
|
|
for (@{$terms->{$term}}) { |
|
|
print STDOUT qq[<dd>].get_node_link ($_).qq[</dd>]; |
|
|
} |
|
|
} |
|
|
print STDOUT qq[</dl></div>]; |
|
|
} # print_term_section |
|
|
|
|
|
sub print_class_section ($) { |
|
|
my $classes = shift; |
|
|
|
|
|
push @nav, ['#classes' => 'Classes']; |
|
|
print STDOUT qq[ |
|
|
<div id="classes" class="section"> |
|
|
<h2>Classes</h2> |
|
|
|
|
|
<dl> |
|
|
]; |
|
|
for my $class (sort {$a cmp $b} keys %$classes) { |
|
|
print STDOUT qq[<dt><code>@{[htescape $class]}</code></dt>]; |
|
|
for (@{$classes->{$class}}) { |
|
|
print STDOUT qq[<dd>].get_node_link ($_).qq[</dd>]; |
|
|
} |
|
|
} |
|
|
print STDOUT qq[</dl></div>]; |
|
|
} # print_class_section |
|
| 710 |
|
|
| 711 |
sub print_result_section ($) { |
sub print_result_section ($) { |
| 712 |
my $result = shift; |
my $result = shift; |
| 818 |
</div> |
</div> |
| 819 |
]; |
]; |
| 820 |
push @nav, ['#parse-errors' => 'Errors']; |
push @nav, ['#parse-errors' => 'Errors']; |
| 821 |
add_error (char => {level => 'unsupported'} => $result); |
add_error (char => {level => 'u'} => $result); |
| 822 |
add_error (syntax => {level => 'unsupported'} => $result); |
add_error (syntax => {level => 'u'} => $result); |
| 823 |
add_error (structure => {level => 'unsupported'} => $result); |
add_error (structure => {level => 'u'} => $result); |
| 824 |
} # print_result_unknown_type_section |
} # print_result_unknown_type_section |
| 825 |
|
|
| 826 |
sub print_result_input_error_section ($) { |
sub print_result_input_error_section ($) { |
| 829 |
<p><em><strong>Input Error</strong>: @{[htescape ($input->{error_status_text})]}</em></p> |
<p><em><strong>Input Error</strong>: @{[htescape ($input->{error_status_text})]}</em></p> |
| 830 |
</div>]; |
</div>]; |
| 831 |
push @nav, ['#result-summary' => 'Result']; |
push @nav, ['#result-summary' => 'Result']; |
| 832 |
} # print_Result_input_error_section |
} # print_result_input_error_section |
| 833 |
|
|
| 834 |
sub get_error_label ($) { |
sub get_error_label ($$) { |
| 835 |
my $err = shift; |
my ($input, $err) = @_; |
| 836 |
|
|
| 837 |
my $r = ''; |
my $r = ''; |
| 838 |
|
|
| 847 |
|
|
| 848 |
if (defined $err->{node}) { |
if (defined $err->{node}) { |
| 849 |
$r .= ' ' if length $r; |
$r .= ' ' if length $r; |
| 850 |
$r = get_node_link ($err->{node}); |
$r = get_node_link ($input, $err->{node}); |
| 851 |
} |
} |
| 852 |
|
|
| 853 |
if (defined $err->{index}) { |
if (defined $err->{index}) { |
| 877 |
} elsif ($err->{level} eq 'w') { |
} elsif ($err->{level} eq 'w') { |
| 878 |
$r = qq[<strong><a href="../error-description#level-w">Warning</a></strong>: |
$r = qq[<strong><a href="../error-description#level-w">Warning</a></strong>: |
| 879 |
]; |
]; |
| 880 |
} elsif ($err->{level} eq 'unsupported') { |
} elsif ($err->{level} eq 'u' or $err->{level} eq 'unsupported') { |
| 881 |
$r = qq[<strong><a href="../error-description#level-u">Not |
$r = qq[<strong><a href="../error-description#level-u">Not |
| 882 |
supported</a></strong>: ]; |
supported</a></strong>: ]; |
| 883 |
} else { |
} else { |
| 916 |
return join '/', @r; |
return join '/', @r; |
| 917 |
} # get_node_path |
} # get_node_path |
| 918 |
|
|
| 919 |
sub get_node_link ($) { |
sub get_node_link ($$) { |
| 920 |
return qq[<a href="#node-@{[refaddr $_[0]]}">] . |
return qq[<a href="#$_[0]->{id_prefix}node-@{[refaddr $_[1]]}">] . |
| 921 |
htescape (get_node_path ($_[0])) . qq[</a>]; |
htescape (get_node_path ($_[1])) . qq[</a>]; |
| 922 |
} # get_node_link |
} # get_node_link |
| 923 |
|
|
| 924 |
{ |
{ |
| 940 |
sub get_text ($) { |
sub get_text ($) { |
| 941 |
my ($type, $level, $node) = @_; |
my ($type, $level, $node) = @_; |
| 942 |
$type = $level . ':' . $type if defined $level; |
$type = $level . ':' . $type if defined $level; |
| 943 |
|
$level = 'm' unless defined $level; |
| 944 |
my @arg; |
my @arg; |
| 945 |
{ |
{ |
| 946 |
if (defined $Msg->{$type}) { |
if (defined $Msg->{$type}) { |
| 965 |
? htescape ($node->owner_element->manakai_local_name) |
? htescape ($node->owner_element->manakai_local_name) |
| 966 |
: '' |
: '' |
| 967 |
}ge; |
}ge; |
| 968 |
return ($type, $Msg->{$type}->[0], $msg); |
return ($type, 'level-' . $level . ' ' . $Msg->{$type}->[0], $msg); |
| 969 |
} elsif ($type =~ s/:([^:]*)$//) { |
} elsif ($type =~ s/:([^:]*)$//) { |
| 970 |
unshift @arg, $1; |
unshift @arg, $1; |
| 971 |
redo; |
redo; |
| 972 |
} |
} |
| 973 |
} |
} |
| 974 |
return ($type, '', htescape ($_[0])); |
return ($type, 'level-'.$level, htescape ($_[0])); |
| 975 |
} # get_text |
} # get_text |
| 976 |
|
|
| 977 |
} |
} |
| 1027 |
$ua->protocols_allowed ([qw/http/]); |
$ua->protocols_allowed ([qw/http/]); |
| 1028 |
$ua->max_size (1000_000); |
$ua->max_size (1000_000); |
| 1029 |
my $req = HTTP::Request->new (GET => $request_uri); |
my $req = HTTP::Request->new (GET => $request_uri); |
| 1030 |
|
$req->header ('Accept-Encoding' => 'identity, *; q=0'); |
| 1031 |
my $res = $ua->request ($req); |
my $res = $ua->request ($req); |
| 1032 |
## TODO: 401 sets |is_success| true. |
## TODO: 401 sets |is_success| true. |
| 1033 |
if ($res->is_success or $http->get_parameter ('error-page')) { |
if ($res->is_success or $http->get_parameter ('error-page')) { |