86 |
<dd>$char_length byte@{[$char_length == 1 ? '' : 's']}</dd> |
<dd>$char_length byte@{[$char_length == 1 ? '' : 's']}</dd> |
87 |
</dl> |
</dl> |
88 |
</div> |
</div> |
89 |
|
|
90 |
|
<script src="../cc-script.js"></script> |
91 |
]; |
]; |
92 |
|
|
93 |
$input->{id_prefix} = ''; |
$input->{id_prefix} = ''; |
134 |
} elsif ($err->{level} eq 'u' or $err->{level} eq 'unsupported') { |
} elsif ($err->{level} eq 'u' or $err->{level} eq 'unsupported') { |
135 |
$result->{$layer}->{unsupported}++; |
$result->{$layer}->{unsupported}++; |
136 |
$result->{unsupported} = 1; |
$result->{unsupported} = 1; |
137 |
|
} elsif ($err->{level} eq 'i') { |
138 |
|
# |
139 |
} else { |
} else { |
140 |
$result->{$layer}->{must}++; |
$result->{$layer}->{must}++; |
141 |
$result->{$layer}->{score_max} -= 2; |
$result->{$layer}->{score_max} -= 2; |
173 |
'text/xml' => 1, |
'text/xml' => 1, |
174 |
'application/atom+xml' => 1, |
'application/atom+xml' => 1, |
175 |
'application/rss+xml' => 1, |
'application/rss+xml' => 1, |
176 |
'application/svg+xml' => 1, |
'image/svg+xml' => 1, |
177 |
'application/xhtml+xml' => 1, |
'application/xhtml+xml' => 1, |
178 |
'application/xml' => 1, |
'application/xml' => 1, |
179 |
|
## TODO: Should we make all XML MIME Types fall |
180 |
|
## into this category? |
181 |
|
|
182 |
|
'application/rdf+xml' => 1, ## NOTE: This type has different model. |
183 |
}->{$input->{media_type}}) { |
}->{$input->{media_type}}) { |
184 |
($doc, $el) = print_syntax_error_xml_section ($input, $result); |
($doc, $el) = print_syntax_error_xml_section ($input, $result); |
185 |
print_source_string_section ($input, |
print_source_string_section ($input, |
218 |
print_listing_section ({ |
print_listing_section ({ |
219 |
id => 'classes', label => 'Classes', heading => 'Classes', |
id => 'classes', label => 'Classes', heading => 'Classes', |
220 |
}, $input, $elements->{class}) if keys %{$elements->{class}}; |
}, $input, $elements->{class}) if keys %{$elements->{class}}; |
221 |
|
print_uri_section ($input, $elements->{uri}) if keys %{$elements->{uri}}; |
222 |
|
print_rdf_section ($input, $elements->{rdf}) if @{$elements->{rdf}}; |
223 |
} elsif (defined $cssom) { |
} elsif (defined $cssom) { |
224 |
print_structure_dump_cssom_section ($input, $cssom); |
print_structure_dump_cssom_section ($input, $cssom); |
225 |
## TODO: CSSOM validation |
## TODO: CSSOM validation |
300 |
<div id="$input->{id_prefix}parse-errors" class="section"> |
<div id="$input->{id_prefix}parse-errors" class="section"> |
301 |
<h2>Parse Errors</h2> |
<h2>Parse Errors</h2> |
302 |
|
|
303 |
<dl>]; |
<dl id="$input->{id_prefix}parse-errors-list">]; |
304 |
push @nav, ['#parse-errors' => 'Parse Error'] unless $input->{nested}; |
push @nav, ['#parse-errors' => 'Parse Error'] unless $input->{nested}; |
305 |
|
|
306 |
my $onerror = sub { |
my $onerror = sub { |
307 |
my (%opt) = @_; |
my (%opt) = @_; |
308 |
my ($type, $cls, $msg) = get_text ($opt{type}, $opt{level}); |
my ($type, $cls, $msg) = get_text ($opt{type}, $opt{level}); |
309 |
if ($opt{column} > 0) { |
print STDOUT qq[<dt class="$cls">], get_error_label ($input, \%opt), |
310 |
print STDOUT qq[<dt class="$cls"><a href="#$input->{id_prefix}line-$opt{line}">Line $opt{line}</a> column $opt{column}</dt>\n]; |
qq[</dt>]; |
|
} else { |
|
|
$opt{line} = $opt{line} - 1 || 1; |
|
|
print STDOUT qq[<dt class="$cls"><a href="#$input->{id_prefix}line-$opt{line}">Line $opt{line}</a></dt>\n]; |
|
|
} |
|
311 |
$type =~ tr/ /-/; |
$type =~ tr/ /-/; |
312 |
$type =~ s/\|/%7C/g; |
$type =~ s/\|/%7C/g; |
313 |
$msg .= qq[ [<a href="../error-description#@{[htescape ($type)]}">Description</a>]]; |
$msg .= qq[ [<a href="../error-description#@{[htescape ($type)]}">Description</a>]]; |
323 |
if (defined $inner_html_element and length $inner_html_element) { |
if (defined $inner_html_element and length $inner_html_element) { |
324 |
$input->{charset} ||= 'windows-1252'; ## TODO: for now. |
$input->{charset} ||= 'windows-1252'; ## TODO: for now. |
325 |
my $time1 = time; |
my $time1 = time; |
326 |
my $t = Encode::decode ($input->{charset}, $input->{s}); |
my $t = \($input->{s}); |
327 |
|
unless ($input->{is_char_string}) { |
328 |
|
$t = \(Encode::decode ($input->{charset}, $$t)); |
329 |
|
} |
330 |
$time{decode} = time - $time1; |
$time{decode} = time - $time1; |
331 |
|
|
332 |
$el = $doc->create_element_ns |
$el = $doc->create_element_ns |
333 |
('http://www.w3.org/1999/xhtml', [undef, $inner_html_element]); |
('http://www.w3.org/1999/xhtml', [undef, $inner_html_element]); |
334 |
$time1 = time; |
$time1 = time; |
335 |
Whatpm::HTML->set_inner_html ($el, $t, $onerror); |
Whatpm::HTML->set_inner_html ($el, $$t, $onerror); |
336 |
$time{parse} = time - $time1; |
$time{parse} = time - $time1; |
337 |
} else { |
} else { |
338 |
my $time1 = time; |
my $time1 = time; |
339 |
Whatpm::HTML->parse_byte_string |
if ($input->{is_char_string}) { |
340 |
($input->{charset}, $input->{s} => $doc, $onerror); |
Whatpm::HTML->parse_char_string ($input->{s} => $doc, $onerror); |
341 |
|
} else { |
342 |
|
Whatpm::HTML->parse_byte_string |
343 |
|
($input->{charset}, $input->{s} => $doc, $onerror); |
344 |
|
} |
345 |
$time{parse_html} = time - $time1; |
$time{parse_html} = time - $time1; |
346 |
} |
} |
347 |
$doc->manakai_charset ($input->{official_charset}) |
$doc->manakai_charset ($input->{official_charset}) |
361 |
<div id="$input->{id_prefix}parse-errors" class="section"> |
<div id="$input->{id_prefix}parse-errors" class="section"> |
362 |
<h2>Parse Errors</h2> |
<h2>Parse Errors</h2> |
363 |
|
|
364 |
<dl>]; |
<dl id="$input->{id_prefix}parse-errors-list">]; |
365 |
push @nav, ['#parse-errors' => 'Parse Error'] unless $input->{prefix}; |
push @nav, ['#parse-errors' => 'Parse Error'] unless $input->{prefix}; |
366 |
|
|
367 |
my $onerror = sub { |
my $onerror = sub { |
381 |
return 1; |
return 1; |
382 |
}; |
}; |
383 |
|
|
384 |
|
my $t = \($input->{s}); |
385 |
|
if ($input->{is_char_string}) { |
386 |
|
require Encode; |
387 |
|
$t = \(Encode::encode ('utf8', $$t)); |
388 |
|
$input->{charset} = 'utf-8'; |
389 |
|
} |
390 |
|
|
391 |
my $time1 = time; |
my $time1 = time; |
392 |
open my $fh, '<', \($input->{s}); |
open my $fh, '<', $t; |
393 |
my $doc = Message::DOM::XMLParserTemp->parse_byte_stream |
my $doc = Message::DOM::XMLParserTemp->parse_byte_stream |
394 |
($fh => $dom, $onerror, charset => $input->{charset}); |
($fh => $dom, $onerror, charset => $input->{charset}); |
395 |
$time{parse_xml} = time - $time1; |
$time{parse_xml} = time - $time1; |
408 |
require Whatpm::CSS::Parser; |
require Whatpm::CSS::Parser; |
409 |
my $p = Whatpm::CSS::Parser->new; |
my $p = Whatpm::CSS::Parser->new; |
410 |
|
|
|
# if ($parse_mode eq 'q') { |
|
|
# $p->{unitless_px} = 1; |
|
|
# $p->{hashless_color} = 1; |
|
|
# } |
|
|
|
|
411 |
$p->{prop}->{$_} = 1 for qw/ |
$p->{prop}->{$_} = 1 for qw/ |
412 |
|
alignment-baseline |
413 |
background background-attachment background-color background-image |
background background-attachment background-color background-image |
414 |
background-position background-position-x background-position-y |
background-position background-position-x background-position-y |
415 |
background-repeat border border-bottom border-bottom-color |
background-repeat border border-bottom border-bottom-color |
421 |
border-style border-top border-top-color border-top-style border-top-width |
border-style border-top border-top-color border-top-style border-top-width |
422 |
border-width bottom |
border-width bottom |
423 |
caption-side clear clip color content counter-increment counter-reset |
caption-side clear clip color content counter-increment counter-reset |
424 |
cursor direction display empty-cells float font |
cursor direction display dominant-baseline empty-cells float font |
425 |
font-family font-size font-size-adjust font-stretch |
font-family font-size font-size-adjust font-stretch |
426 |
font-style font-variant font-weight height left |
font-style font-variant font-weight height left |
427 |
letter-spacing line-height |
letter-spacing line-height |
433 |
padding padding-bottom padding-left padding-right padding-top |
padding padding-bottom padding-left padding-right padding-top |
434 |
page page-break-after page-break-before page-break-inside |
page page-break-after page-break-before page-break-inside |
435 |
position quotes right size table-layout |
position quotes right size table-layout |
436 |
text-align text-decoration text-indent text-transform |
text-align text-anchor text-decoration text-indent text-transform |
437 |
top unicode-bidi vertical-align visibility white-space width widows |
top unicode-bidi vertical-align visibility white-space width widows |
438 |
word-spacing z-index |
word-spacing writing-mode z-index |
439 |
/; |
/; |
440 |
$p->{prop_value}->{display}->{$_} = 1 for qw/ |
$p->{prop_value}->{display}->{$_} = 1 for qw/ |
441 |
block clip inline inline-block inline-table list-item none |
block clip inline inline-block inline-table list-item none |
512 |
$p->{prop_value}->{'white-space'}->{$_} = 1 for qw/ |
$p->{prop_value}->{'white-space'}->{$_} = 1 for qw/ |
513 |
normal pre nowrap pre-line pre-wrap -moz-pre-wrap |
normal pre nowrap pre-line pre-wrap -moz-pre-wrap |
514 |
/; |
/; |
515 |
|
$p->{prop_value}->{'writing-mode'}->{$_} = 1 for qw/ |
516 |
|
lr rl tb lr-tb rl-tb tb-rl |
517 |
|
/; |
518 |
|
$p->{prop_value}->{'text-anchor'}->{$_} = 1 for qw/ |
519 |
|
start middle end |
520 |
|
/; |
521 |
|
$p->{prop_value}->{'dominant-baseline'}->{$_} = 1 for qw/ |
522 |
|
auto use-script no-change reset-size ideographic alphabetic |
523 |
|
hanging mathematical central middle text-after-edge text-before-edge |
524 |
|
/; |
525 |
|
$p->{prop_value}->{'alignment-baseline'}->{$_} = 1 for qw/ |
526 |
|
auto baseline before-edge text-before-edge middle central |
527 |
|
after-edge text-after-edge ideographic alphabetic hanging |
528 |
|
mathematical |
529 |
|
/; |
530 |
$p->{prop_value}->{'text-decoration'}->{$_} = 1 for qw/ |
$p->{prop_value}->{'text-decoration'}->{$_} = 1 for qw/ |
531 |
none blink underline overline line-through |
none blink underline overline line-through |
532 |
/; |
/; |
579 |
<div id="$input->{id_prefix}parse-errors" class="section"> |
<div id="$input->{id_prefix}parse-errors" class="section"> |
580 |
<h2>Parse Errors</h2> |
<h2>Parse Errors</h2> |
581 |
|
|
582 |
<dl>]; |
<dl id="$input->{id_prefix}parse-errors-list">]; |
583 |
push @nav, ['#parse-errors' => 'Parse Error'] unless $input->{nested}; |
push @nav, ['#parse-errors' => 'Parse Error'] unless $input->{nested}; |
584 |
|
|
585 |
my $p = get_css_parser (); |
my $p = get_css_parser (); |
586 |
|
$p->init; |
587 |
$p->{onerror} = sub { |
$p->{onerror} = sub { |
588 |
my (%opt) = @_; |
my (%opt) = @_; |
589 |
my ($type, $cls, $msg) = get_text ($opt{type}, $opt{level}); |
my ($type, $cls, $msg) = get_text ($opt{type}, $opt{level}); |
608 |
$p->{href} = $input->{uri}; |
$p->{href} = $input->{uri}; |
609 |
$p->{base_uri} = $input->{base_uri}; |
$p->{base_uri} = $input->{base_uri}; |
610 |
|
|
611 |
|
# if ($parse_mode eq 'q') { |
612 |
|
# $p->{unitless_px} = 1; |
613 |
|
# $p->{hashless_color} = 1; |
614 |
|
# } |
615 |
|
|
616 |
|
## TODO: Make $input->{s} a ref. |
617 |
|
|
618 |
my $s = \$input->{s}; |
my $s = \$input->{s}; |
619 |
my $charset; |
my $charset; |
620 |
unless ($input->{is_char_string}) { |
unless ($input->{is_char_string}) { |
645 |
<div id="$input->{id_prefix}parse-errors" class="section"> |
<div id="$input->{id_prefix}parse-errors" class="section"> |
646 |
<h2>Parse Errors</h2> |
<h2>Parse Errors</h2> |
647 |
|
|
648 |
<dl>]; |
<dl id="$input->{id_prefix}parse-errors-list">]; |
649 |
push @nav, ['#parse-errors' => 'Parse Error'] unless $input->{nested}; |
push @nav, ['#parse-errors' => 'Parse Error'] unless $input->{nested}; |
650 |
|
|
651 |
my $onerror = sub { |
my $onerror = sub { |
662 |
add_error ('syntax', \%opt => $result); |
add_error ('syntax', \%opt => $result); |
663 |
}; |
}; |
664 |
|
|
665 |
|
my $m = $input->{is_char_string} ? 'parse_char_string' : 'parse_byte_string'; |
666 |
my $time1 = time; |
my $time1 = time; |
667 |
my $manifest = Whatpm::CacheManifest->parse_byte_string |
my $manifest = Whatpm::CacheManifest->$m |
668 |
($input->{s}, $input->{uri}, $input->{base_uri}, $onerror); |
($input->{s}, $input->{uri}, $input->{base_uri}, $onerror); |
669 |
$time{parse_manifest} = time - $time1; |
$time{parse_manifest} = time - $time1; |
670 |
|
|
692 |
<h2>Document Source</h2> |
<h2>Document Source</h2> |
693 |
<ol lang="">\n]; |
<ol lang="">\n]; |
694 |
if (length $$s) { |
if (length $$s) { |
695 |
while ($$s =~ /\G([^\x0A]*?)\x0D?\x0A/gc) { |
while ($$s =~ /\G([^\x0D\x0A]*?)(?>\x0D\x0A?|\x0A)/gc) { |
696 |
print STDOUT qq[<li id="$input->{id_prefix}line-$i">], htescape $1, |
print STDOUT qq[<li id="$input->{id_prefix}line-$i">], htescape $1, |
697 |
"</li>\n"; |
"</li>\n"; |
698 |
$i++; |
$i++; |
699 |
} |
} |
700 |
if ($$s =~ /\G([^\x0A]+)/gc) { |
if ($$s =~ /\G([^\x0D\x0A]+)/gc) { |
701 |
print STDOUT qq[<li id="$input->{id_prefix}line-$i">], htescape $1, |
print STDOUT qq[<li id="$input->{id_prefix}line-$i">], htescape $1, |
702 |
"</li>\n"; |
"</li>\n"; |
703 |
} |
} |
704 |
} else { |
} else { |
705 |
print STDOUT q[<li id="$input->{id_prefix}line-1"></li>]; |
print STDOUT q[<li id="$input->{id_prefix}line-1"></li>]; |
706 |
} |
} |
707 |
print STDOUT "</ol></div>"; |
print STDOUT "</ol></div> |
708 |
|
<script> |
709 |
|
addSourceToParseErrorList ('$input->{id_prefix}', 'parse-errors-list'); |
710 |
|
</script>"; |
711 |
} # print_input_string_section |
} # print_input_string_section |
712 |
|
|
713 |
sub print_document_tree ($$) { |
sub print_document_tree ($$) { |
845 |
unless $input->{nested}; |
unless $input->{nested}; |
846 |
|
|
847 |
print STDOUT qq[<dl><dt>Explicit entries</dt>]; |
print STDOUT qq[<dl><dt>Explicit entries</dt>]; |
848 |
|
my $i = 0; |
849 |
for my $uri (@{$manifest->[0]}) { |
for my $uri (@{$manifest->[0]}) { |
850 |
my $euri = htescape ($uri); |
my $euri = htescape ($uri); |
851 |
print STDOUT qq[<dd><code class=uri><<a href="$euri">$euri</a>></code></dd>]; |
print STDOUT qq[<dd id="$input->{id_prefix}index-@{[$i++]}"><code class=uri><<a href="$euri">$euri</a>></code></dd>]; |
852 |
} |
} |
853 |
|
|
854 |
print STDOUT qq[<dt>Fallback entries</dt><dd> |
print STDOUT qq[<dt>Fallback entries</dt><dd> |
857 |
for my $uri (sort {$a cmp $b} keys %{$manifest->[1]}) { |
for my $uri (sort {$a cmp $b} keys %{$manifest->[1]}) { |
858 |
my $euri = htescape ($uri); |
my $euri = htescape ($uri); |
859 |
my $euri2 = htescape ($manifest->[1]->{$uri}); |
my $euri2 = htescape ($manifest->[1]->{$uri}); |
860 |
print STDOUT qq[<tr><td><code class=uri><<a href="$euri">$euri</a>></code></td> |
print STDOUT qq[<tr><td id="$input->{id_prefix}index-@{[$i++]}"><code class=uri><<a href="$euri">$euri</a>></code></td> |
861 |
<td><code class=uri><<a href="$euri2">$euri2</a>></code></td>]; |
<td id="$input->{id_prefix}index-@{[$i++]}"><code class=uri><<a href="$euri2">$euri2</a>></code></td>]; |
862 |
} |
} |
863 |
|
|
864 |
print STDOUT qq[</table><dt>Online whitelist</dt>]; |
print STDOUT qq[</table><dt>Online whitelist</dt>]; |
865 |
for my $uri (@{$manifest->[2]}) { |
for my $uri (@{$manifest->[2]}) { |
866 |
my $euri = htescape ($uri); |
my $euri = htescape ($uri); |
867 |
print STDOUT qq[<dd><code class=uri><<a href="$euri">$euri</a>></code></dd>]; |
print STDOUT qq[<dd id="$input->{id_prefix}index-@{[$i++]}"><code class=uri><<a href="$euri">$euri</a>></code></dd>]; |
868 |
} |
} |
869 |
|
|
870 |
print STDOUT qq[</dl></div>]; |
print STDOUT qq[</dl></div>]; |
876 |
print STDOUT qq[<div id="$input->{id_prefix}document-errors" class="section"> |
print STDOUT qq[<div id="$input->{id_prefix}document-errors" class="section"> |
877 |
<h2>Document Errors</h2> |
<h2>Document Errors</h2> |
878 |
|
|
879 |
<dl>]; |
<dl id=document-errors-list>]; |
880 |
push @nav, [qq[#$input->{id_prefix}document-errors] => 'Document Error'] |
push @nav, [qq[#$input->{id_prefix}document-errors] => 'Document Error'] |
881 |
unless $input->{nested}; |
unless $input->{nested}; |
882 |
|
|
904 |
} |
} |
905 |
$time{check} = time - $time1; |
$time{check} = time - $time1; |
906 |
|
|
907 |
print STDOUT qq[</dl></div>]; |
print STDOUT qq[</dl> |
908 |
|
<script> |
909 |
|
addSourceToParseErrorList ('$input->{id_prefix}', 'document-errors-list'); |
910 |
|
</script></div>]; |
911 |
|
|
912 |
return $elements; |
return $elements; |
913 |
} # print_structure_error_dom_section |
} # print_structure_error_dom_section |
1018 |
print STDOUT qq[</dl></div>]; |
print STDOUT qq[</dl></div>]; |
1019 |
} # print_listing_section |
} # print_listing_section |
1020 |
|
|
1021 |
|
sub print_uri_section ($$$) { |
1022 |
|
my ($input, $uris) = @_; |
1023 |
|
|
1024 |
|
## NOTE: URIs contained in the DOM (i.e. in HTML or XML documents), |
1025 |
|
## except for those in RDF triples. |
1026 |
|
## TODO: URIs in CSS |
1027 |
|
|
1028 |
|
push @nav, ['#' . $input->{id_prefix} . 'uris' => 'URIs'] |
1029 |
|
unless $input->{nested}; |
1030 |
|
print STDOUT qq[ |
1031 |
|
<div id="$input->{id_prefix}uris" class="section"> |
1032 |
|
<h2>URIs</h2> |
1033 |
|
|
1034 |
|
<dl>]; |
1035 |
|
for my $uri (sort {$a cmp $b} keys %$uris) { |
1036 |
|
my $euri = htescape ($uri); |
1037 |
|
print STDOUT qq[<dt><code class=uri><<a href="$euri">$euri</a>></code>]; |
1038 |
|
my $eccuri = htescape (get_cc_uri ($uri)); |
1039 |
|
print STDOUT qq[<dd><a href="$eccuri">Check conformance of this document</a>]; |
1040 |
|
print STDOUT qq[<dd>Found at: <ul>]; |
1041 |
|
for my $entry (@{$uris->{$uri}}) { |
1042 |
|
print STDOUT qq[<li>], get_node_link ($input, $entry->{node}); |
1043 |
|
if (keys %{$entry->{type} or {}}) { |
1044 |
|
print STDOUT ' ('; |
1045 |
|
print STDOUT join ', ', map { |
1046 |
|
{ |
1047 |
|
hyperlink => 'Hyperlink', |
1048 |
|
resource => 'Link to an external resource', |
1049 |
|
namespace => 'Namespace URI', |
1050 |
|
cite => 'Citation or link to a long description', |
1051 |
|
embedded => 'Link to an embedded content', |
1052 |
|
base => 'Base URI', |
1053 |
|
action => 'Submission URI', |
1054 |
|
}->{$_} |
1055 |
|
or |
1056 |
|
htescape ($_) |
1057 |
|
} keys %{$entry->{type}}; |
1058 |
|
print STDOUT ')'; |
1059 |
|
} |
1060 |
|
} |
1061 |
|
print STDOUT qq[</ul>]; |
1062 |
|
} |
1063 |
|
print STDOUT qq[</dl></div>]; |
1064 |
|
} # print_uri_section |
1065 |
|
|
1066 |
|
sub print_rdf_section ($$$) { |
1067 |
|
my ($input, $rdfs) = @_; |
1068 |
|
|
1069 |
|
push @nav, ['#' . $input->{id_prefix} . 'rdf' => 'RDF'] |
1070 |
|
unless $input->{nested}; |
1071 |
|
print STDOUT qq[ |
1072 |
|
<div id="$input->{id_prefix}rdf" class="section"> |
1073 |
|
<h2>RDF Triples</h2> |
1074 |
|
|
1075 |
|
<dl>]; |
1076 |
|
my $i = 0; |
1077 |
|
for my $rdf (@$rdfs) { |
1078 |
|
print STDOUT qq[<dt id="$input->{id_prefix}rdf-@{[$i++]}">]; |
1079 |
|
print STDOUT get_node_link ($input, $rdf->[0]); |
1080 |
|
print STDOUT qq[<dd><dl>]; |
1081 |
|
for my $triple (@{$rdf->[1]}) { |
1082 |
|
print STDOUT '<dt>' . get_node_link ($input, $triple->[0]) . '<dd>'; |
1083 |
|
print STDOUT get_rdf_resource_html ($triple->[1]); |
1084 |
|
print STDOUT ' '; |
1085 |
|
print STDOUT get_rdf_resource_html ($triple->[2]); |
1086 |
|
print STDOUT ' '; |
1087 |
|
print STDOUT get_rdf_resource_html ($triple->[3]); |
1088 |
|
} |
1089 |
|
print STDOUT qq[</dl>]; |
1090 |
|
} |
1091 |
|
print STDOUT qq[</dl></div>]; |
1092 |
|
} # print_rdf_section |
1093 |
|
|
1094 |
|
sub get_rdf_resource_html ($) { |
1095 |
|
my $resource = shift; |
1096 |
|
if (defined $resource->{uri}) { |
1097 |
|
my $euri = htescape ($resource->{uri}); |
1098 |
|
return '<code class=uri><<a href="' . $euri . '">' . $euri . |
1099 |
|
'</a>></code>'; |
1100 |
|
} elsif (defined $resource->{bnodeid}) { |
1101 |
|
return htescape ('_:' . $resource->{bnodeid}); |
1102 |
|
} elsif ($resource->{nodes}) { |
1103 |
|
return '(rdf:XMLLiteral)'; |
1104 |
|
} elsif (defined $resource->{value}) { |
1105 |
|
my $elang = htescape (defined $resource->{language} |
1106 |
|
? $resource->{language} : ''); |
1107 |
|
my $r = qq[<q lang="$elang">] . htescape ($resource->{value}) . '</q>'; |
1108 |
|
if (defined $resource->{datatype}) { |
1109 |
|
my $euri = htescape ($resource->{datatype}); |
1110 |
|
$r .= '^^<code class=uri><<a href="' . $euri . '">' . $euri . |
1111 |
|
'</a>></code>'; |
1112 |
|
} elsif (length $resource->{language}) { |
1113 |
|
$r .= '@' . htescape ($resource->{language}); |
1114 |
|
} |
1115 |
|
return $r; |
1116 |
|
} else { |
1117 |
|
return '??'; |
1118 |
|
} |
1119 |
|
} # get_rdf_resource_html |
1120 |
|
|
1121 |
sub print_result_section ($) { |
sub print_result_section ($) { |
1122 |
my $result = shift; |
my $result = shift; |
1123 |
|
|
1247 |
|
|
1248 |
my $r = ''; |
my $r = ''; |
1249 |
|
|
1250 |
if (defined $err->{line}) { |
my $line; |
1251 |
if ($err->{column} > 0) { |
my $column; |
1252 |
$r = qq[<a href="#$input->{id_prefix}line-$err->{line}">Line $err->{line}</a> column $err->{column}]; |
|
1253 |
|
if (defined $err->{node}) { |
1254 |
|
$line = $err->{node}->get_user_data ('manakai_source_line'); |
1255 |
|
if (defined $line) { |
1256 |
|
$column = $err->{node}->get_user_data ('manakai_source_column'); |
1257 |
|
} else { |
1258 |
|
if ($err->{node}->node_type == $err->{node}->ATTRIBUTE_NODE) { |
1259 |
|
my $owner = $err->{node}->owner_element; |
1260 |
|
$line = $owner->get_user_data ('manakai_source_line'); |
1261 |
|
$column = $owner->get_user_data ('manakai_source_column'); |
1262 |
|
} else { |
1263 |
|
my $parent = $err->{node}->parent_node; |
1264 |
|
if ($parent) { |
1265 |
|
$line = $parent->get_user_data ('manakai_source_line'); |
1266 |
|
$column = $parent->get_user_data ('manakai_source_column'); |
1267 |
|
} |
1268 |
|
} |
1269 |
|
} |
1270 |
|
} |
1271 |
|
unless (defined $line) { |
1272 |
|
if (defined $err->{token} and defined $err->{token}->{line}) { |
1273 |
|
$line = $err->{token}->{line}; |
1274 |
|
$column = $err->{token}->{column}; |
1275 |
|
} elsif (defined $err->{line}) { |
1276 |
|
$line = $err->{line}; |
1277 |
|
$column = $err->{column}; |
1278 |
|
} |
1279 |
|
} |
1280 |
|
|
1281 |
|
if (defined $line) { |
1282 |
|
if (defined $column and $column > 0) { |
1283 |
|
$r = qq[<a href="#$input->{id_prefix}line-$line">Line $line</a> column $column]; |
1284 |
} else { |
} else { |
1285 |
$err->{line} = $err->{line} - 1 || 1; |
$line = $line - 1 || 1; |
1286 |
$r = qq[<a href="#$input->{id_prefix}line-$err->{line}">Line $err->{line}</a>]; |
$r = qq[<a href="#$input->{id_prefix}line-$line">Line $line</a>]; |
1287 |
} |
} |
1288 |
} |
} |
1289 |
|
|
1290 |
if (defined $err->{node}) { |
if (defined $err->{node}) { |
1291 |
$r .= ' ' if length $r; |
$r .= ' ' if length $r; |
1292 |
$r = get_node_link ($input, $err->{node}); |
$r .= get_node_link ($input, $err->{node}); |
1293 |
} |
} |
1294 |
|
|
1295 |
if (defined $err->{index}) { |
if (defined $err->{index}) { |
1296 |
$r .= ' ' if length $r; |
if (length $r) { |
1297 |
$r .= 'Index ' . (0+$err->{index}); |
$r .= ', Index ' . (0+$err->{index}); |
1298 |
|
} else { |
1299 |
|
$r .= "<a href='#$input->{id_prefix}index-@{[0+$err->{index}]}'>Index " |
1300 |
|
. (0+$err->{index}) . '</a>'; |
1301 |
|
} |
1302 |
} |
} |
1303 |
|
|
1304 |
if (defined $err->{value}) { |
if (defined $err->{value}) { |
1326 |
} elsif ($err->{level} eq 'u' or $err->{level} eq 'unsupported') { |
} elsif ($err->{level} eq 'u' or $err->{level} eq 'unsupported') { |
1327 |
$r = qq[<strong><a href="../error-description#level-u">Not |
$r = qq[<strong><a href="../error-description#level-u">Not |
1328 |
supported</a></strong>: ]; |
supported</a></strong>: ]; |
1329 |
|
} elsif ($err->{level} eq 'i') { |
1330 |
|
$r = qq[<strong><a href="../error-description#level-i">Information</a></strong>: ]; |
1331 |
} else { |
} else { |
1332 |
my $elevel = htescape ($err->{level}); |
my $elevel = htescape ($err->{level}); |
1333 |
$r = qq[<strong><a href="../error-description#level-$elevel">$elevel</a></strong>: |
$r = qq[<strong><a href="../error-description#level-$elevel">$elevel</a></strong>: |
1343 |
while (defined $node) { |
while (defined $node) { |
1344 |
my $rs; |
my $rs; |
1345 |
if ($node->node_type == 1) { |
if ($node->node_type == 1) { |
1346 |
$rs = $node->manakai_local_name; |
$rs = $node->node_name; |
1347 |
$node = $node->parent_node; |
$node = $node->parent_node; |
1348 |
} elsif ($node->node_type == 2) { |
} elsif ($node->node_type == 2) { |
1349 |
$rs = '@' . $node->manakai_local_name; |
$rs = '@' . $node->node_name; |
1350 |
$node = $node->owner_element; |
$node = $node->owner_element; |
1351 |
} elsif ($node->node_type == 3) { |
} elsif ($node->node_type == 3) { |
1352 |
$rs = '"' . $node->data . '"'; |
$rs = '"' . $node->data . '"'; |
1424 |
|
|
1425 |
} |
} |
1426 |
|
|
1427 |
|
sub encode_uri_component ($) { |
1428 |
|
require Encode; |
1429 |
|
my $s = Encode::encode ('utf8', shift); |
1430 |
|
$s =~ s/([^0-9A-Za-z_.~-])/sprintf '%%%02X', ord $1/ge; |
1431 |
|
return $s; |
1432 |
|
} # encode_uri_component |
1433 |
|
|
1434 |
|
sub get_cc_uri ($) { |
1435 |
|
return './?uri=' . encode_uri_component ($_[0]); |
1436 |
|
} # get_cc_uri |
1437 |
|
|
1438 |
sub get_input_document ($$) { |
sub get_input_document ($$) { |
1439 |
my ($http, $dom) = @_; |
my ($http, $dom) = @_; |
1440 |
|
|