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 |
|
|
157 |
my $self = shift; |
my $self = shift; |
158 |
|
|
159 |
my $out = $self->output; |
my $out = $self->output; |
160 |
$out->start_section (id => 'document-errors', title => 'Document Errors'); |
$out->start_section (role => 'structure-errors'); |
161 |
$out->start_tag ('dl', class => 'document-errors-list'); |
$out->start_error_list (role => 'structure-errors'); |
162 |
|
|
163 |
my $input = $self->input; |
my $input = $self->input; |
164 |
my $result = $self->result; |
my $result = $self->result; |
177 |
($self->{structure}, $onerror, $onsubdoc); |
($self->{structure}, $onerror, $onsubdoc); |
178 |
} |
} |
179 |
|
|
180 |
$out->end_tag ('dl'); |
$out->end_error_list (role => 'structure-errors'); |
|
$out->html (qq[<script> |
|
|
addSourceToParseErrorList ('@{[$input->id_prefix]}', 'document-errors-list'); |
|
|
</script>]); |
|
181 |
$out->end_section; |
$out->end_section; |
182 |
} # generate_structure_error_section |
} # generate_structure_error_section |
183 |
|
|
184 |
|
sub generate_additional_sections ($) { |
185 |
|
my $self = shift; |
186 |
|
$self->SUPER::generate_additional_sections; |
187 |
|
|
188 |
|
$self->generate_table_section; |
189 |
|
|
190 |
|
$self->generate_listing_section ( |
191 |
|
key => 'id', id => 'identifiers', |
192 |
|
short_title => 'IDs', title => 'Identifiers', |
193 |
|
); |
194 |
|
$self->generate_listing_section ( |
195 |
|
key => 'term', id => 'terms', |
196 |
|
short_title => 'Terms', title => 'Terms', |
197 |
|
); |
198 |
|
$self->generate_listing_section ( |
199 |
|
key => 'class', id => 'classes', |
200 |
|
short_title => 'Classes', title => 'Classes', |
201 |
|
); |
202 |
|
|
203 |
|
$self->generate_rdf_section; |
204 |
|
} # generate_additional_sections |
205 |
|
|
206 |
|
sub generate_table_section ($) { |
207 |
|
my $self = shift; |
208 |
|
|
209 |
|
my $tables = $self->{add_info}->{table} || []; |
210 |
|
return unless @$tables; |
211 |
|
|
212 |
|
my $out = $self->output; |
213 |
|
$out->start_section (id => 'tables', title => 'Tables'); |
214 |
|
|
215 |
|
$out->html (q[<!--[if IE]><script type="text/javascript" src="../excanvas.js"></script><![endif]--> |
216 |
|
<script src="../table-script.js" type="text/javascript"></script> |
217 |
|
<noscript> |
218 |
|
<p><em>Structure of tables are visualized here if scripting is enabled.</em></p> |
219 |
|
</noscript>]); |
220 |
|
|
221 |
|
require JSON; |
222 |
|
|
223 |
|
my $i = 0; |
224 |
|
for my $table (@$tables) { |
225 |
|
$i++; |
226 |
|
my $index = $out->input->full_subdocument_index; |
227 |
|
$index = $index ? $index . '.' . $i : $i; |
228 |
|
$out->start_section (id => 'table-' . $i, |
229 |
|
title => 'Table #' . $index); |
230 |
|
|
231 |
|
$out->start_tag ('dl'); |
232 |
|
$out->dt ('Table Element'); |
233 |
|
$out->start_tag ('dd'); |
234 |
|
$out->node_link ($table->{element}); |
235 |
|
$out->end_tag ('dl'); |
236 |
|
delete $table->{element}; |
237 |
|
|
238 |
|
for (@{$table->{column_group}}, @{$table->{column}}, $table->{caption}, |
239 |
|
@{$table->{row}}) { |
240 |
|
next unless $_; |
241 |
|
delete $_->{element}; |
242 |
|
} |
243 |
|
|
244 |
|
for (@{$table->{row_group}}) { |
245 |
|
next unless $_; |
246 |
|
next unless $_->{element}; |
247 |
|
$_->{type} = $_->{element}->manakai_local_name; |
248 |
|
delete $_->{element}; |
249 |
|
} |
250 |
|
|
251 |
|
for (@{$table->{cell}}) { |
252 |
|
next unless $_; |
253 |
|
for (@{$_}) { |
254 |
|
next unless $_; |
255 |
|
for (@$_) { |
256 |
|
$_->{id} = refaddr $_->{element} if defined $_->{element}; |
257 |
|
delete $_->{element}; |
258 |
|
$_->{is_header} = $_->{is_header} ? 1 : 0; |
259 |
|
} |
260 |
|
} |
261 |
|
} |
262 |
|
|
263 |
|
my $id_prefix = $self->input->id_prefix; |
264 |
|
$out->script (q[tableToCanvas (] . |
265 |
|
JSON::objToJson ($table) . |
266 |
|
q[, document.getElementById ('] . $id_prefix . 'table-' . $i . q[')] . |
267 |
|
q[, '] . $id_prefix . q[');]); |
268 |
|
|
269 |
|
$out->end_section; |
270 |
|
} |
271 |
|
|
272 |
|
$out->end_section; |
273 |
|
} # generate_table_section |
274 |
|
|
275 |
|
sub generate_listing_section ($%) { |
276 |
|
my $self = shift; |
277 |
|
my %opt = @_; |
278 |
|
|
279 |
|
my $list = $self->{add_info}->{$opt{key}} || {}; |
280 |
|
return unless keys %$list; |
281 |
|
|
282 |
|
my $out = $self->output; |
283 |
|
|
284 |
|
$out->start_section (id => $opt{id}, |
285 |
|
title => $opt{title}, |
286 |
|
short_title => $opt{short_title}); |
287 |
|
$out->start_tag ('dl'); |
288 |
|
|
289 |
|
for my $id (sort {$a cmp $b} keys %$list) { |
290 |
|
$out->start_tag ('dt'); |
291 |
|
$out->code ($id); |
292 |
|
for (@{$list->{$id}}) { |
293 |
|
$out->start_tag ('dd'); |
294 |
|
$out->node_link ($_); |
295 |
|
} |
296 |
|
} |
297 |
|
|
298 |
|
$out->end_tag ('dl'); |
299 |
|
$out->end_section; |
300 |
|
} # generate_listing_section |
301 |
|
|
302 |
|
my $generate_rdf_resource_html = sub ($$) { |
303 |
|
my ($resource, $out) = @_; |
304 |
|
|
305 |
|
if (defined $resource->{uri}) { |
306 |
|
$out->url ($resource->{uri}); |
307 |
|
} elsif (defined $resource->{bnodeid}) { |
308 |
|
$out->text ('_:' . $resource->{bnodeid}); |
309 |
|
} elsif ($resource->{nodes}) { |
310 |
|
$out->text ('(rdf:XMLLiteral)'); |
311 |
|
} elsif (defined $resource->{value}) { |
312 |
|
$out->start_tag ('q', |
313 |
|
lang => defined $resource->{language} |
314 |
|
? $resource->{language} : ''); |
315 |
|
$out->text ($resource->{value}); |
316 |
|
$out->end_tag ('q'); |
317 |
|
|
318 |
|
if (defined $resource->{datatype}) { |
319 |
|
$out->text ('^^'); |
320 |
|
$out->url ($resource->{datatype}); |
321 |
|
} elsif (length $resource->{language}) { |
322 |
|
$out->text ('@' . $resource->{language}); |
323 |
|
} |
324 |
|
} else { |
325 |
|
$out->text ('??'); ## NOTE: An error of the implementation. |
326 |
|
} |
327 |
|
}; # $generate_rdf_resource_html |
328 |
|
|
329 |
|
## TODO: Should we move this method to another module, |
330 |
|
## such as Base or RDF? |
331 |
|
sub generate_rdf_section ($) { |
332 |
|
my $self = shift; |
333 |
|
|
334 |
|
my $list = $self->{add_info}->{rdf} || []; |
335 |
|
return unless @$list; |
336 |
|
|
337 |
|
my $out = $self->output; |
338 |
|
$out->start_section (id => 'rdf', short_title => 'RDF', |
339 |
|
title => 'RDF Triples'); |
340 |
|
$out->start_tag ('dl'); |
341 |
|
|
342 |
|
my $i = 0; |
343 |
|
for my $rdf (@$list) { |
344 |
|
$out->start_tag ('dt', id => 'rdf-' . $i++); |
345 |
|
$out->node_link ($rdf->[0]); |
346 |
|
$out->start_tag ('dd'); |
347 |
|
$out->start_tag ('dl'); |
348 |
|
for my $triple (@{$rdf->[1]}) { |
349 |
|
$out->start_tag ('dt'); |
350 |
|
$out->node_link ($triple->[0]); |
351 |
|
$out->start_tag ('dd'); |
352 |
|
$out->text ('Subject: '); |
353 |
|
$generate_rdf_resource_html->($triple->[1] => $out); |
354 |
|
$out->start_tag ('dd'); |
355 |
|
$out->text ('Predicate: '); |
356 |
|
$generate_rdf_resource_html->($triple->[2] => $out); |
357 |
|
$out->start_tag ('dd'); |
358 |
|
$out->text ('Object: '); |
359 |
|
$generate_rdf_resource_html->($triple->[3] => $out); |
360 |
|
} |
361 |
|
$out->end_tag ('dl'); |
362 |
|
} |
363 |
|
$out->end_tag ('dl'); |
364 |
|
$out->end_section; |
365 |
|
} # generate_rdf_section |
366 |
|
|
367 |
1; |
1; |