10 |
|
|
11 |
my $out = $self->output; |
my $out = $self->output; |
12 |
|
|
13 |
$out->start_section (id => 'document-tree', title => 'Document Tree', |
$out->start_section (role => 'tree'); |
|
short_title => 'Tree'); |
|
14 |
|
|
15 |
$out->start_tag ('ol', class => 'xoxo'); |
$out->start_tag ('ol', class => 'xoxo'); |
16 |
|
|
82 |
$out->end_tag ('code'); |
$out->end_tag ('code'); |
83 |
} elsif ($nt == $child->DOCUMENT_NODE) { |
} elsif ($nt == $child->DOCUMENT_NODE) { |
84 |
$out->start_tag ('li', id => $node_id, class => 'tree-document'); |
$out->start_tag ('li', id => $node_id, class => 'tree-document'); |
85 |
$out->text ('Document'); |
$out->nl_text ('Document'); |
86 |
|
|
87 |
$out->start_tag ('ul', class => 'attributes'); |
$out->start_tag ('ul', class => 'attributes'); |
88 |
|
|
89 |
my $cp = $child->manakai_charset; |
my $cp = $child->manakai_charset; |
90 |
if (defined $cp) { |
if (defined $cp) { |
91 |
$out->html (qq[<li><code>charset</code> parameter = <code>]); |
$out->start_tag ('li'); |
92 |
$out->text ($cp); |
$out->nl_text ('manakaiCharset'); |
93 |
$out->html ('</code>'); |
$out->text (' = '); |
94 |
|
$out->code ($cp); |
95 |
} |
} |
96 |
$out->html (qq[<li><code>inputEncoding</code> = ]); |
|
97 |
|
$out->start_tag ('li'); |
98 |
|
$out->nl_text ('inputEncoding'); |
99 |
|
$out->text (' = '); |
100 |
my $ie = $child->input_encoding; |
my $ie = $child->input_encoding; |
101 |
if (defined $ie) { |
if (defined $ie) { |
102 |
$out->code ($ie); |
$out->code ($ie); |
103 |
if ($child->manakai_has_bom) { |
if ($child->manakai_has_bom) { |
104 |
$out->html (qq[ (with <code class=charname><abbr>BOM</abbr></code>)]); |
$out->nl_text ('... with BOM'); |
105 |
} |
} |
106 |
} else { |
} else { |
107 |
$out->html (qq[(<code>null</code>)]); |
$out->html (qq[(<code>null</code>)]); |
108 |
} |
} |
109 |
$out->html (qq[<li>@{[scalar main::get_text ('manakaiIsHTML:'.($child->manakai_is_html?1:0))]}</li>]); |
|
110 |
$out->html (qq[<li>@{[scalar main::get_text ('manakaiCompatMode:'.$child->manakai_compat_mode)]}</li>]); |
$out->start_tag ('li'); |
111 |
|
$out->nl_text ('manakaiIsHTML:'.($child->manakai_is_html?1:0)); |
112 |
|
|
113 |
|
$out->start_tag ('li'); |
114 |
|
$out->nl_text ('manakaiCompatMode:'.$child->manakai_compat_mode); |
115 |
|
|
116 |
unless ($child->manakai_is_html) { |
unless ($child->manakai_is_html) { |
117 |
$out->html (qq[<li>XML version = ]); |
$out->start_tag ('li'); |
118 |
|
$out->nl_text ('xmlVersion'); |
119 |
|
$out->text (' = '); |
120 |
$out->code ($child->xml_version); |
$out->code ($child->xml_version); |
121 |
|
|
122 |
|
$out->start_tag ('li'); |
123 |
|
$out->nl_text ('xmlEncoding'); |
124 |
|
$out->text (' = '); |
125 |
if (defined $child->xml_encoding) { |
if (defined $child->xml_encoding) { |
|
$out->html (qq[<li>XML encoding = ]); |
|
126 |
$out->code ($child->xml_encoding); |
$out->code ($child->xml_encoding); |
127 |
} else { |
} else { |
128 |
$out->html (qq[<li>XML encoding = (null)</li>]); |
$out->html ('(<code>null</code>)'); |
129 |
} |
} |
130 |
$out->html (qq[<li>XML standalone = @{[$child->xml_standalone ? 'true' : 'false']}</li>]); |
|
131 |
|
$out->start_tag ('li'); |
132 |
|
$out->nl_text ('xmlStandalone'); |
133 |
|
$out->text (' = '); |
134 |
|
$out->code ($child->xml_standalone ? 'true' : 'false'); |
135 |
} |
} |
136 |
|
|
137 |
$out->end_tag ('ul'); |
$out->end_tag ('ul'); |
138 |
|
|
139 |
if ($child->has_child_nodes) { |
if ($child->has_child_nodes) { |
140 |
$out->start_tag ('ol', class => 'children'); |
$out->start_tag ('ol', class => 'children'); |
141 |
unshift @node, @{$child->child_nodes}, '</ol></li>'; |
unshift @node, @{$child->child_nodes}, '</ol></li>'; |
179 |
my $self = shift; |
my $self = shift; |
180 |
|
|
181 |
my $out = $self->output; |
my $out = $self->output; |
182 |
$out->start_section (id => 'document-errors', title => 'Document Errors'); |
$out->start_section (role => 'structure-errors'); |
183 |
$out->start_tag ('dl', class => 'document-errors-list'); |
$out->start_error_list (role => 'structure-errors'); |
184 |
|
$self->result->layer_applicable ('structure'); |
185 |
|
|
186 |
my $input = $self->input; |
my $input = $self->input; |
187 |
my $result = $self->result; |
my $result = $self->result; |
188 |
|
|
189 |
require Whatpm::ContentChecker; |
require Whatpm::ContentChecker; |
190 |
my $onerror = sub { |
my $onerror = sub { |
191 |
my %opt = @_; |
$result->add_error (layer => 'structure', @_); |
|
my ($type, $cls, $msg) = main::get_text ($opt{type}, $opt{level}, $opt{node}); |
|
|
$type =~ tr/ /-/; |
|
|
$type =~ s/\|/%7C/g; |
|
|
$out->html (qq[<dt class="$cls">] . $result->get_error_label ($input, \%opt)); |
|
|
$out->html (qq[<dd class="$cls">] . $result->get_error_level_label (\%opt)); |
|
|
$out->html ($msg); |
|
|
$out->text (' ['); |
|
|
$out->link ('Description', url => '../error-description#' . $type); |
|
|
$out->text (']'); |
|
|
main::add_error ('structure', \%opt => $result); |
|
192 |
}; |
}; |
193 |
|
|
194 |
my $onsubdoc = $self->onsubdoc; |
my $onsubdoc = $self->onsubdoc; |
200 |
($self->{structure}, $onerror, $onsubdoc); |
($self->{structure}, $onerror, $onsubdoc); |
201 |
} |
} |
202 |
|
|
203 |
$out->end_tag ('dl'); |
$out->end_error_list (role => 'structure-errors'); |
|
$out->html (qq[<script> |
|
|
addSourceToParseErrorList ('@{[$input->id_prefix]}', 'document-errors-list'); |
|
|
</script>]); |
|
204 |
$out->end_section; |
$out->end_section; |
205 |
|
|
206 |
|
$self->result->layer_uncertain ('semantics'); |
207 |
} # generate_structure_error_section |
} # generate_structure_error_section |
208 |
|
|
209 |
|
sub generate_additional_sections ($) { |
210 |
|
my $self = shift; |
211 |
|
$self->SUPER::generate_additional_sections; |
212 |
|
|
213 |
|
$self->generate_table_section; |
214 |
|
|
215 |
|
$self->generate_listing_section ( |
216 |
|
key => 'id', id => 'identifiers', |
217 |
|
short_title => 'IDs', title => 'Identifiers', |
218 |
|
); |
219 |
|
$self->generate_listing_section ( |
220 |
|
key => 'term', id => 'terms', |
221 |
|
short_title => 'Terms', title => 'Terms', |
222 |
|
); |
223 |
|
$self->generate_listing_section ( |
224 |
|
key => 'class', id => 'classes', |
225 |
|
short_title => 'Classes', title => 'Classes', |
226 |
|
); |
227 |
|
|
228 |
|
$self->generate_rdf_section; |
229 |
|
} # generate_additional_sections |
230 |
|
|
231 |
|
sub generate_table_section ($) { |
232 |
|
my $self = shift; |
233 |
|
|
234 |
|
my $tables = $self->{add_info}->{table} || []; |
235 |
|
return unless @$tables; |
236 |
|
|
237 |
|
my $out = $self->output; |
238 |
|
$out->start_section (id => 'tables', short_title => 'Tables', |
239 |
|
title => 'Tables Section'); |
240 |
|
|
241 |
|
$out->html (q[<!--[if IE]><script type="text/javascript" src="../excanvas.js"></script><![endif]--> |
242 |
|
<script src="../table-script.js" type="text/javascript"></script> |
243 |
|
<noscript> |
244 |
|
<p><em>Structure of tables are visualized here if scripting is enabled.</em></p> |
245 |
|
</noscript>]); |
246 |
|
|
247 |
|
require JSON; |
248 |
|
|
249 |
|
my $i = 0; |
250 |
|
for my $table (@$tables) { |
251 |
|
$i++; |
252 |
|
my $index = $out->input->full_subdocument_index; |
253 |
|
$index = $index ? $index . '.' . $i : $i; |
254 |
|
$out->start_section (id => 'table-' . $i, |
255 |
|
title => 'Table #', |
256 |
|
text => $index, |
257 |
|
notab => 1); |
258 |
|
|
259 |
|
$out->start_tag ('dl'); |
260 |
|
$out->dt ('Table Element'); |
261 |
|
$out->start_tag ('dd'); |
262 |
|
$out->node_link ($table->{element}); |
263 |
|
$out->end_tag ('dl'); |
264 |
|
delete $table->{element}; |
265 |
|
|
266 |
|
for (@{$table->{column_group}}, @{$table->{column}}, $table->{caption}, |
267 |
|
@{$table->{row}}) { |
268 |
|
next unless $_; |
269 |
|
delete $_->{element}; |
270 |
|
} |
271 |
|
|
272 |
|
for (@{$table->{row_group}}) { |
273 |
|
next unless $_; |
274 |
|
next unless $_->{element}; |
275 |
|
$_->{type} = $_->{element}->manakai_local_name; |
276 |
|
delete $_->{element}; |
277 |
|
} |
278 |
|
|
279 |
|
for (@{$table->{cell}}) { |
280 |
|
next unless $_; |
281 |
|
for (@{$_}) { |
282 |
|
next unless $_; |
283 |
|
for (@$_) { |
284 |
|
$_->{id} = refaddr $_->{element} if defined $_->{element}; |
285 |
|
delete $_->{element}; |
286 |
|
$_->{is_header} = $_->{is_header} ? 1 : 0; |
287 |
|
} |
288 |
|
} |
289 |
|
} |
290 |
|
|
291 |
|
my $id_prefix = $self->input->id_prefix; |
292 |
|
$out->script (q[tableToCanvas (] . |
293 |
|
JSON::objToJson ($table) . |
294 |
|
q[, document.getElementById ('] . $id_prefix . 'table-' . $i . q[')] . |
295 |
|
q[, '] . $id_prefix . q[');]); |
296 |
|
|
297 |
|
$out->end_section; |
298 |
|
} |
299 |
|
|
300 |
|
$out->end_section; |
301 |
|
} # generate_table_section |
302 |
|
|
303 |
|
sub generate_listing_section ($%) { |
304 |
|
my $self = shift; |
305 |
|
my %opt = @_; |
306 |
|
|
307 |
|
my $list = $self->{add_info}->{$opt{key}} || {}; |
308 |
|
return unless keys %$list; |
309 |
|
|
310 |
|
my $out = $self->output; |
311 |
|
|
312 |
|
$out->start_section (id => $opt{id}, |
313 |
|
title => $opt{title}, |
314 |
|
short_title => $opt{short_title}); |
315 |
|
$out->start_tag ('dl'); |
316 |
|
|
317 |
|
for my $id (sort {$a cmp $b} keys %$list) { |
318 |
|
$out->start_tag ('dt'); |
319 |
|
$out->code ($id); |
320 |
|
for (@{$list->{$id}}) { |
321 |
|
$out->start_tag ('dd'); |
322 |
|
$out->node_link ($_); |
323 |
|
} |
324 |
|
} |
325 |
|
|
326 |
|
$out->end_tag ('dl'); |
327 |
|
$out->end_section; |
328 |
|
} # generate_listing_section |
329 |
|
|
330 |
|
my $generate_rdf_resource_html = sub ($$) { |
331 |
|
my ($resource, $out) = @_; |
332 |
|
|
333 |
|
if (defined $resource->{uri}) { |
334 |
|
$out->url ($resource->{uri}); |
335 |
|
} elsif (defined $resource->{bnodeid}) { |
336 |
|
$out->text ('_:' . $resource->{bnodeid}); |
337 |
|
} elsif ($resource->{nodes}) { |
338 |
|
$out->text ('(rdf:XMLLiteral)'); |
339 |
|
} elsif (defined $resource->{value}) { |
340 |
|
$out->start_tag ('q', |
341 |
|
lang => defined $resource->{language} |
342 |
|
? $resource->{language} : ''); |
343 |
|
$out->text ($resource->{value}); |
344 |
|
$out->end_tag ('q'); |
345 |
|
|
346 |
|
if (defined $resource->{datatype}) { |
347 |
|
$out->text ('^^'); |
348 |
|
$out->url ($resource->{datatype}); |
349 |
|
} elsif (length $resource->{language}) { |
350 |
|
$out->text ('@' . $resource->{language}); |
351 |
|
} |
352 |
|
} else { |
353 |
|
$out->text ('??'); ## NOTE: An error of the implementation. |
354 |
|
} |
355 |
|
}; # $generate_rdf_resource_html |
356 |
|
|
357 |
|
## TODO: Should we move this method to another module, |
358 |
|
## such as Base or RDF? |
359 |
|
sub generate_rdf_section ($) { |
360 |
|
my $self = shift; |
361 |
|
|
362 |
|
my $list = $self->{add_info}->{rdf} || []; |
363 |
|
return unless @$list; |
364 |
|
|
365 |
|
my $out = $self->output; |
366 |
|
$out->start_section (id => 'rdf', short_title => 'RDF', |
367 |
|
title => 'RDF Triples'); |
368 |
|
$out->start_tag ('dl'); |
369 |
|
|
370 |
|
my $i = 0; |
371 |
|
for my $rdf (@$list) { |
372 |
|
$out->start_tag ('dt', id => 'rdf-' . $i++); |
373 |
|
$out->node_link ($rdf->[0]); |
374 |
|
$out->start_tag ('dd'); |
375 |
|
$out->start_tag ('dl'); |
376 |
|
for my $triple (@{$rdf->[1]}) { |
377 |
|
$out->start_tag ('dt'); |
378 |
|
$out->node_link ($triple->[0]); |
379 |
|
$out->start_tag ('dd'); |
380 |
|
$out->nl_text ('Subject'); |
381 |
|
$out->text (': '); |
382 |
|
$generate_rdf_resource_html->($triple->[1] => $out); |
383 |
|
$out->start_tag ('dd'); |
384 |
|
$out->nl_text ('Predicate'); |
385 |
|
$out->text (': '); |
386 |
|
$generate_rdf_resource_html->($triple->[2] => $out); |
387 |
|
$out->start_tag ('dd'); |
388 |
|
$out->nl_text ('Object'); |
389 |
|
$out->text (': '); |
390 |
|
$generate_rdf_resource_html->($triple->[3] => $out); |
391 |
|
} |
392 |
|
$out->end_tag ('dl'); |
393 |
|
} |
394 |
|
$out->end_tag ('dl'); |
395 |
|
$out->end_section; |
396 |
|
} # generate_rdf_section |
397 |
|
|
398 |
1; |
1; |