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_rdf_section ($input, $elements->{rdf}) if @{$elements->{rdf}}; |
222 |
} elsif (defined $cssom) { |
} elsif (defined $cssom) { |
223 |
print_structure_dump_cssom_section ($input, $cssom); |
print_structure_dump_cssom_section ($input, $cssom); |
224 |
## TODO: CSSOM validation |
## TODO: CSSOM validation |
676 |
<h2>Document Source</h2> |
<h2>Document Source</h2> |
677 |
<ol lang="">\n]; |
<ol lang="">\n]; |
678 |
if (length $$s) { |
if (length $$s) { |
679 |
while ($$s =~ /\G([^\x0A]*?)\x0D?\x0A/gc) { |
while ($$s =~ /\G([^\x0D\x0A]*?)(?>\x0D\x0A?|\x0A)/gc) { |
680 |
print STDOUT qq[<li id="$input->{id_prefix}line-$i">], htescape $1, |
print STDOUT qq[<li id="$input->{id_prefix}line-$i">], htescape $1, |
681 |
"</li>\n"; |
"</li>\n"; |
682 |
$i++; |
$i++; |
683 |
} |
} |
684 |
if ($$s =~ /\G([^\x0A]+)/gc) { |
if ($$s =~ /\G([^\x0D\x0A]+)/gc) { |
685 |
print STDOUT qq[<li id="$input->{id_prefix}line-$i">], htescape $1, |
print STDOUT qq[<li id="$input->{id_prefix}line-$i">], htescape $1, |
686 |
"</li>\n"; |
"</li>\n"; |
687 |
} |
} |
689 |
print STDOUT q[<li id="$input->{id_prefix}line-1"></li>]; |
print STDOUT q[<li id="$input->{id_prefix}line-1"></li>]; |
690 |
} |
} |
691 |
print STDOUT "</ol></div> |
print STDOUT "</ol></div> |
692 |
<script> addSourceToParseErrorList ('$input->{id_prefix}'); </script>"; |
<script> |
693 |
|
addSourceToParseErrorList ('$input->{id_prefix}', 'parse-errors-list'); |
694 |
|
</script>"; |
695 |
} # print_input_string_section |
} # print_input_string_section |
696 |
|
|
697 |
sub print_document_tree ($$) { |
sub print_document_tree ($$) { |
860 |
print STDOUT qq[<div id="$input->{id_prefix}document-errors" class="section"> |
print STDOUT qq[<div id="$input->{id_prefix}document-errors" class="section"> |
861 |
<h2>Document Errors</h2> |
<h2>Document Errors</h2> |
862 |
|
|
863 |
<dl>]; |
<dl id=document-errors-list>]; |
864 |
push @nav, [qq[#$input->{id_prefix}document-errors] => 'Document Error'] |
push @nav, [qq[#$input->{id_prefix}document-errors] => 'Document Error'] |
865 |
unless $input->{nested}; |
unless $input->{nested}; |
866 |
|
|
888 |
} |
} |
889 |
$time{check} = time - $time1; |
$time{check} = time - $time1; |
890 |
|
|
891 |
print STDOUT qq[</dl></div>]; |
print STDOUT qq[</dl> |
892 |
|
<script> |
893 |
|
addSourceToParseErrorList ('$input->{id_prefix}', 'document-errors-list'); |
894 |
|
</script></div>]; |
895 |
|
|
896 |
return $elements; |
return $elements; |
897 |
} # print_structure_error_dom_section |
} # print_structure_error_dom_section |
1002 |
print STDOUT qq[</dl></div>]; |
print STDOUT qq[</dl></div>]; |
1003 |
} # print_listing_section |
} # print_listing_section |
1004 |
|
|
1005 |
|
sub print_rdf_section ($$$) { |
1006 |
|
my ($input, $rdfs) = @_; |
1007 |
|
|
1008 |
|
push @nav, ['#' . $input->{id_prefix} . 'rdf' => 'RDF'] |
1009 |
|
unless $input->{nested}; |
1010 |
|
print STDOUT qq[ |
1011 |
|
<div id="$input->{id_prefix}rdf" class="section"> |
1012 |
|
<h2>RDF Triples</h2> |
1013 |
|
|
1014 |
|
<dl>]; |
1015 |
|
my $i = 0; |
1016 |
|
for my $rdf (@$rdfs) { |
1017 |
|
print STDOUT qq[<dt id="$input->{id_prefix}rdf-@{[$i++]}">]; |
1018 |
|
print STDOUT get_node_link ($input, $rdf->[0]); |
1019 |
|
print STDOUT qq[<dd><dl>]; |
1020 |
|
for my $triple (@{$rdf->[1]}) { |
1021 |
|
print STDOUT '<dt>' . get_node_link ($input, $triple->[0]) . '<dd>'; |
1022 |
|
print STDOUT get_rdf_resource_html ($triple->[1]); |
1023 |
|
print STDOUT ' '; |
1024 |
|
print STDOUT get_rdf_resource_html ($triple->[2]); |
1025 |
|
print STDOUT ' '; |
1026 |
|
print STDOUT get_rdf_resource_html ($triple->[3]); |
1027 |
|
} |
1028 |
|
print STDOUT qq[</dl>]; |
1029 |
|
} |
1030 |
|
print STDOUT qq[</dl></div>]; |
1031 |
|
} # print_rdf_section |
1032 |
|
|
1033 |
|
sub get_rdf_resource_html ($) { |
1034 |
|
my $resource = shift; |
1035 |
|
if (defined $resource->{uri}) { |
1036 |
|
my $euri = htescape ($resource->{uri}); |
1037 |
|
return '<code class=uri><<a href="' . $euri . '">' . $euri . |
1038 |
|
'</a>></code>'; |
1039 |
|
} elsif (defined $resource->{bnodeid}) { |
1040 |
|
return htescape ('_:' . $resource->{bnodeid}); |
1041 |
|
} elsif ($resource->{nodes}) { |
1042 |
|
return '(rdf:XMLLiteral)'; |
1043 |
|
} elsif (defined $resource->{value}) { |
1044 |
|
my $elang = htescape (defined $resource->{language} |
1045 |
|
? $resource->{language} : ''); |
1046 |
|
my $r = qq[<q lang="$elang">] . htescape ($resource->{value}) . '</q>'; |
1047 |
|
if (defined $resource->{datatype}) { |
1048 |
|
my $euri = htescape ($resource->{datatype}); |
1049 |
|
$r .= '^^<code class=uri><<a href="' . $euri . '">' . $euri . |
1050 |
|
'</a>></code>'; |
1051 |
|
} elsif (length $resource->{language}) { |
1052 |
|
$r .= '@' . htescape ($resource->{language}); |
1053 |
|
} |
1054 |
|
return $r; |
1055 |
|
} else { |
1056 |
|
return '??'; |
1057 |
|
} |
1058 |
|
} # get_rdf_resource_html |
1059 |
|
|
1060 |
sub print_result_section ($) { |
sub print_result_section ($) { |
1061 |
my $result = shift; |
my $result = shift; |
1062 |
|
|
1186 |
|
|
1187 |
my $r = ''; |
my $r = ''; |
1188 |
|
|
1189 |
if (defined $err->{line}) { |
my $line; |
1190 |
if ($err->{column} > 0) { |
my $column; |
1191 |
$r = qq[<a href="#$input->{id_prefix}line-$err->{line}">Line $err->{line}</a> column $err->{column}]; |
|
1192 |
|
if (defined $err->{node}) { |
1193 |
|
$line = $err->{node}->get_user_data ('manakai_source_line'); |
1194 |
|
if (defined $line) { |
1195 |
|
$column = $err->{node}->get_user_data ('manakai_source_column'); |
1196 |
|
} else { |
1197 |
|
if ($err->{node}->node_type == $err->{node}->ATTRIBUTE_NODE) { |
1198 |
|
my $owner = $err->{node}->owner_element; |
1199 |
|
$line = $owner->get_user_data ('manakai_source_line'); |
1200 |
|
$column = $owner->get_user_data ('manakai_source_column'); |
1201 |
|
} else { |
1202 |
|
my $parent = $err->{node}->parent_node; |
1203 |
|
if ($parent) { |
1204 |
|
$line = $parent->get_user_data ('manakai_source_line'); |
1205 |
|
$column = $parent->get_user_data ('manakai_source_column'); |
1206 |
|
} |
1207 |
|
} |
1208 |
|
} |
1209 |
|
} |
1210 |
|
unless (defined $line) { |
1211 |
|
if (defined $err->{token} and defined $err->{token}->{line}) { |
1212 |
|
$line = $err->{token}->{line}; |
1213 |
|
$column = $err->{token}->{column}; |
1214 |
|
} elsif (defined $err->{line}) { |
1215 |
|
$line = $err->{line}; |
1216 |
|
$column = $err->{column}; |
1217 |
|
} |
1218 |
|
} |
1219 |
|
|
1220 |
|
if (defined $line) { |
1221 |
|
if (defined $column and $column > 0) { |
1222 |
|
$r = qq[<a href="#$input->{id_prefix}line-$line">Line $line</a> column $column]; |
1223 |
} else { |
} else { |
1224 |
$err->{line} = $err->{line} - 1 || 1; |
$line = $line - 1 || 1; |
1225 |
$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>]; |
1226 |
} |
} |
1227 |
} |
} |
1228 |
|
|
1229 |
if (defined $err->{node}) { |
if (defined $err->{node}) { |
1230 |
$r .= ' ' if length $r; |
$r .= ' ' if length $r; |
1231 |
$r = get_node_link ($input, $err->{node}); |
$r .= get_node_link ($input, $err->{node}); |
1232 |
} |
} |
1233 |
|
|
1234 |
if (defined $err->{index}) { |
if (defined $err->{index}) { |
1282 |
while (defined $node) { |
while (defined $node) { |
1283 |
my $rs; |
my $rs; |
1284 |
if ($node->node_type == 1) { |
if ($node->node_type == 1) { |
1285 |
$rs = $node->manakai_local_name; |
$rs = $node->node_name; |
1286 |
$node = $node->parent_node; |
$node = $node->parent_node; |
1287 |
} elsif ($node->node_type == 2) { |
} elsif ($node->node_type == 2) { |
1288 |
$rs = '@' . $node->manakai_local_name; |
$rs = '@' . $node->node_name; |
1289 |
$node = $node->owner_element; |
$node = $node->owner_element; |
1290 |
} elsif ($node->node_type == 3) { |
} elsif ($node->node_type == 3) { |
1291 |
$rs = '"' . $node->data . '"'; |
$rs = '"' . $node->data . '"'; |