--- test/html-webhacc/cc.cgi 2008/07/20 16:53:10 1.54 +++ test/html-webhacc/cc.cgi 2008/07/21 08:39:12 1.56 @@ -44,85 +44,20 @@ ]); my $input = get_input_document ($http, $dom); + $out->input ($input); $out->unset_flush; - my $char_length = 0; - - $out->start_section (id => 'document-info', title => 'Information'); - $out->html (qq[
-
Request URL
-
]); - $out->url ($input->{request_uri}); - $out->html (q[
Document URL -
]); - $out->url ($input->{uri}, id => 'anchor-document-url'); - $out->html (q[ - ]); - ## NOTE: no
yet - - if (defined $input->{s}) { - $char_length = length $input->{s}; - - $out->html (qq[
Base URI
]); - $out->url ($input->{base_uri}); - $out->html (qq[
Internet Media Type
-
]); - $out->text ($input->{media_type}); - $out->html (qq[ ]); - if ($input->{media_type_overridden}) { - $out->html ('(overridden)'); - } elsif (defined $input->{official_type}) { - if ($input->{media_type} eq $input->{official_type}) { - # - } else { - $out->html ('(sniffed; official type is: '); - $out->text ($input->{official_type}); - $out->html (')'); - } - } else { - $out->html ('(sniffed)'); - } - $out->html (q[
Character Encoding
]); - if (defined $input->{charset}) { - $out->html (''); - $out->text ($input->{charset}); - $out->html (''); - } else { - $out->text ('(none)'); - } - $out->html (' overridden') if $input->{charset_overridden}; - $out->html (qq[ -
Length
-
$char_length byte@{[$char_length == 1 ? '' : 's']}
- - - -]); - $out->end_section; - - my $result = WebHACC::Result->new; - $result->output ($out); - $result->{conforming_min} = 1; - $result->{conforming_max} = 1; - check_and_print ($input => $result => $out); - $result->generate_result_section; - } else { - $out->html (''); - $out->end_section; + my $result = WebHACC::Result->new; + $result->output ($out); + $result->{conforming_min} = 1; + $result->{conforming_max} = 1; - my $result = WebHACC::Result->new; - $result->output ($out); - $result->{conforming_min} = 0; - $result->{conforming_max} = 1; + $out->html (''); - $input->generate_transfer_sections ($result); - $result->generate_result_section; - } + check_and_print ($input => $result => $out); + + $result->generate_result_section; $out->nav_list; @@ -134,9 +69,14 @@ my $original_input = $out->input; $out->input ($input); + $input->generate_info_section ($result); + $input->generate_transfer_sections ($result); - my @subdoc; + unless (defined $input->{s}) { + $result->{conforming_min} = 0; + return; + } my $checker_class = { 'text/cache-manifest' => 'WebHACC::Language::CacheManifest', @@ -169,6 +109,7 @@ $checker->generate_syntax_error_section; $checker->generate_source_string_section; + my @subdoc; $checker->onsubdoc (sub { push @subdoc, shift; }); @@ -181,7 +122,6 @@ if (defined $doc or defined $el) { - print_table_section ($input, $elements->{table}) if @{$elements->{table}}; print_listing_section ({ id => 'identifiers', label => 'IDs', heading => 'Identifiers', }, $input, $elements->{id}) if keys %{$elements->{id}}; @@ -199,169 +139,20 @@ my $id_prefix = 0; for my $_subinput (@subdoc) { - my $subinput = WebHACC::Input->new; + my $subinput = WebHACC::Input::Subdocument->new (++$id_prefix); $subinput->{$_} = $_subinput->{$_} for keys %$_subinput; - $subinput->id_prefix ('subdoc-' . ++$id_prefix); - $subinput->nested (1); $subinput->{base_uri} = $subinput->{container_node}->base_uri unless defined $subinput->{base_uri}; - my $ebaseuri = htescape ($subinput->{base_uri}); - $out->start_section (id => $subinput->id_prefix, - title => qq[Subdocument #$id_prefix]); - print STDOUT qq[ -
-
Internet Media Type
-
@{[htescape $subinput->{media_type}]} -
Container Node
-
@{[get_node_link ($input, $subinput->{container_node})]}
-
Base URI
-
<$ebaseuri>
-
]; + $subinput->{parent_input} = $input; - $subinput->{id_prefix} .= '-'; + $subinput->start_section ($result); check_and_print ($subinput => $result => $out); - - $out->end_section; + $subinput->end_section ($result); } $out->input ($original_input); } # check_and_print -sub print_table_section ($$) { - my ($input, $tables) = @_; - -# push @nav, [qq[#$input->{id_prefix}tables] => 'Tables'] -# unless $input->{nested}; - print STDOUT qq[ -
-

Tables

- - - - -]; - - require JSON; - - my $i = 0; - for my $table (@$tables) { - $i++; - print STDOUT qq[

] . - get_node_link ($input, $table->{element}) . q[

]; - - delete $table->{element}; - - for (@{$table->{column_group}}, @{$table->{column}}, $table->{caption}, - @{$table->{row}}) { - next unless $_; - delete $_->{element}; - } - - for (@{$table->{row_group}}) { - next unless $_; - next unless $_->{element}; - $_->{type} = $_->{element}->manakai_local_name; - delete $_->{element}; - } - - for (@{$table->{cell}}) { - next unless $_; - for (@{$_}) { - next unless $_; - for (@$_) { - $_->{id} = refaddr $_->{element} if defined $_->{element}; - delete $_->{element}; - $_->{is_header} = $_->{is_header} ? 1 : 0; - } - } - } - - print STDOUT '
]; - } - - print STDOUT qq[
]; -} # print_table_section - -sub print_listing_section ($$$) { - my ($opt, $input, $ids) = @_; - -# push @nav, ['#' . $input->{id_prefix} . $opt->{id} => $opt->{label}] -# unless $input->{nested}; - print STDOUT qq[ -
-

$opt->{heading}

- -
-]; - for my $id (sort {$a cmp $b} keys %$ids) { - print STDOUT qq[
@{[htescape $id]}
]; - for (@{$ids->{$id}}) { - print STDOUT qq[
].get_node_link ($input, $_).qq[
]; - } - } - print STDOUT qq[
]; -} # print_listing_section - - -sub print_rdf_section ($$$) { - my ($input, $rdfs) = @_; - -# push @nav, ['#' . $input->{id_prefix} . 'rdf' => 'RDF'] -# unless $input->{nested}; - print STDOUT qq[ -
-

RDF Triples

- -
]; - my $i = 0; - for my $rdf (@$rdfs) { - print STDOUT qq[
]; - print STDOUT get_node_link ($input, $rdf->[0]); - print STDOUT qq[
]; - for my $triple (@{$rdf->[1]}) { - print STDOUT '
' . get_node_link ($input, $triple->[0]) . '
'; - print STDOUT get_rdf_resource_html ($triple->[1]); - print STDOUT ' '; - print STDOUT get_rdf_resource_html ($triple->[2]); - print STDOUT ' '; - print STDOUT get_rdf_resource_html ($triple->[3]); - } - print STDOUT qq[
]; - } - print STDOUT qq[
]; -} # print_rdf_section - -sub get_rdf_resource_html ($) { - my $resource = shift; - if (defined $resource->{uri}) { - my $euri = htescape ($resource->{uri}); - return '<' . $euri . - '>'; - } elsif (defined $resource->{bnodeid}) { - return htescape ('_:' . $resource->{bnodeid}); - } elsif ($resource->{nodes}) { - return '(rdf:XMLLiteral)'; - } elsif (defined $resource->{value}) { - my $elang = htescape (defined $resource->{language} - ? $resource->{language} : ''); - my $r = qq[] . htescape ($resource->{value}) . ''; - if (defined $resource->{datatype}) { - my $euri = htescape ($resource->{datatype}); - $r .= '^^<' . $euri . - '>'; - } elsif (length $resource->{language}) { - $r .= '@' . htescape ($resource->{language}); - } - return $r; - } else { - return '??'; - } -} # get_rdf_resource_html { my $Msg = {}; @@ -616,4 +407,4 @@ =cut -## $Date: 2008/07/20 16:53:10 $ +## $Date: 2008/07/21 08:39:12 $