--- test/html-webhacc/cc.cgi 2007/06/27 12:35:24 1.2
+++ test/html-webhacc/cc.cgi 2007/06/30 08:26:08 1.5
@@ -33,30 +33,26 @@
exit;
}
+ my @nav;
print STDOUT qq[Content-Type: text/html; charset=utf-8
Web Document Conformance Checker (BETA)
-
-
+
Web Document Conformance Checker (beta)
+
- Document URI
<@{[htescape $input_uri]}>
- Internet Media Type
@{[htescape $input_format]}
]; # no
yet
+ push @nav, ['#document-info' => 'Information'];
require Message::DOM::DOMImplementation;
my $dom = Message::DOM::DOMImplementation->____new;
@@ -73,9 +69,12 @@
Character Encoding
(none)
+
+
Document Source
];
+ push @nav, ['#source-string' => 'Source'];
print_source_string (\$s);
print STDOUT qq[
@@ -83,18 +82,19 @@
Parse Errors
-
+
];
+ push @nav, ['#parse-errors' => 'Parse Error'];
my $onerror = sub {
my (%opt) = @_;
if ($opt{column} > 0) {
- print STDOUT qq[
- Line $opt{line} column $opt{column}: ];
+ print STDOUT qq[
- Line $opt{line} column $opt{column}
\n];
} else {
$opt{line}--;
- print STDOUT qq[ - Line $opt{line}: ];
+ print STDOUT qq[
- Line $opt{line}
\n];
}
- print STDOUT qq[@{[htescape $opt{type}]} \n];
+ print STDOUT qq[- @{[htescape $opt{type}]}
\n];
};
$doc = $dom->create_document;
@@ -107,7 +107,7 @@
}
print STDOUT qq[
-
+
];
} elsif ($input_format eq 'application/xhtml+xml') {
@@ -120,9 +120,12 @@
Character Encoding
(none)
+
+
Document Source
];
+ push @nav, ['#source-string' => 'Source'];
print_source_string (\$t);
print STDOUT qq[
@@ -130,15 +133,16 @@
Parse Errors
-
+
];
+ push @nav, ['#parse-errors' => 'Parse Error'];
my $onerror = sub {
my $err = shift;
my $line = $err->location->line_number;
- print STDOUT qq[
- Line $line column ];
- print STDOUT $err->location->column_number, ": ";
- print STDOUT htescape $err->text, "
\n";
+ print STDOUT qq[- Line $line column ];
+ print STDOUT $err->location->column_number, "
- ";
+ print STDOUT htescape $err->text, "
\n";
return 1;
};
@@ -147,15 +151,19 @@
($fh => $dom, $onerror, charset => 'utf-8');
print STDOUT qq[
-
+
];
} else {
print STDOUT qq[
+
+
Media type @{[htescape $input_format]}
is not supported!
+
];
+ push @nav, ['#result-summary' => 'Result'];
}
@@ -164,6 +172,7 @@
Document Tree
];
+ push @nav, ['#document-tree' => 'Tree'];
print_document_tree ($el || $doc);
@@ -173,31 +182,96 @@
Document Errors
-
+
];
+ push @nav, ['#document-errors' => 'Document Error'];
require Whatpm::ContentChecker;
my $onerror = sub {
my %opt = @_;
- print STDOUT qq[
- ],
+ print STDOUT qq[
- ],
htescape get_node_path ($opt{node}),
- ": ", htescape $opt{type}, "
\n";
+ "\n- ", htescape $opt{type}, "
\n";
};
+ my $elements;
if ($el) {
- Whatpm::ContentChecker->check_element ($el, $onerror);
+ $elements = Whatpm::ContentChecker->check_element ($el, $onerror);
} else {
- Whatpm::ContentChecker->check_document ($doc, $onerror);
+ $elements = Whatpm::ContentChecker->check_document ($doc, $onerror);
}
print STDOUT qq[
-
+
];
+
+ if (@{$elements->{table}}) {
+ require JSON;
+
+ print STDOUT qq[
+
+
Tables
+
+
+
+
+];
+
+ my $i = 0;
+ for my $table_el (@{$elements->{table}}) {
+ $i++;
+ print STDOUT qq[
\n];
+
+ my $table = Whatpm::HTMLTable->form_table ($table_el);
+
+ for (@{$table->{column_group}}, @{$table->{column}}, $table->{caption}) {
+ 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};
+ }
+ }
+ }
+
+ print STDOUT '
];
+ }
+
+ print STDOUT qq[
];
+ }
}
## TODO: Show result
+
+ print STDOUT qq[
+
+];
+ for (@nav) {
+ print STDOUT qq[- $_->[1]
];
+ }
print STDOUT qq[
+
];
@@ -233,14 +307,15 @@
my $node_id = 'node-'.refaddr $child;
my $nt = $child->node_type;
if ($nt == $child->ELEMENT_NODE) {
- $r .= qq'
' . htescape ($child->tag_name) .
+ my $child_nsuri = $child->namespace_uri;
+ $r .= qq[] . htescape ($child->tag_name) .
'
'; ## ISSUE: case
if ($child->has_attributes) {
$r .= '';
- for my $attr (sort {$a->[0] cmp $b->[0]} map { [$_->name, $_->value, 'node-'.refaddr $_] }
+ for my $attr (sort {$a->[0] cmp $b->[0]} map { [$_->name, $_->value, $_->namespace_uri, 'node-'.refaddr $_] }
@{$child->attributes}) {
- $r .= qq'' . htescape ($attr->[0]) . '
= '; ## ISSUE: case?
+ $r .= qq[] . htescape ($attr->[0]) . '
= '; ## ISSUE: case?
$r .= '' . htescape ($attr->[1]) . '
'; ## TODO: children
}
$r .= '
';
@@ -251,28 +326,27 @@
unshift @node, @{$child->child_nodes}, '';
}
} elsif ($nt == $child->TEXT_NODE) {
- $r .= qq'' . htescape ($child->data) . '
';
+ $r .= qq'' . htescape ($child->data) . '
';
} elsif ($nt == $child->CDATA_SECTION_NODE) {
- $r .= qq'<[CDATA[
' . htescape ($child->data) . '
]]>
';
+ $r .= qq'<[CDATA[
' . htescape ($child->data) . '
]]>
';
} elsif ($nt == $child->COMMENT_NODE) {
- $r .= qq'<!--
' . htescape ($child->data) . '
-->
';
+ $r .= qq'';
} elsif ($nt == $child->DOCUMENT_NODE) {
- $r .= qq'Document';
+ $r .= qq'Document';
if ($child->has_child_nodes) {
$r .= '';
unshift @node, @{$child->child_nodes}, '
';
}
} elsif ($nt == $child->DOCUMENT_TYPE_NODE) {
- $r .= qq'<!DOCTYPE>
';
- $r .= '- Name =
@{[htescape ($child->name)]}
';
- $r .= '- Public identifier =
@{[htescape ($child->public_id)]}
';
- $r .= '- System identifier =
@{[htescape ($child->system_id)]}
';
+ $r .= qq'<!DOCTYPE>
';
+ $r .= qq[- Name =
@{[htescape ($child->name)]}
];
+ $r .= qq[- Public identifier =
@{[htescape ($child->public_id)]}
];
+ $r .= qq[- System identifier =
@{[htescape ($child->system_id)]}
];
$r .= '
';
} elsif ($nt == $child->PROCESSING_INSTRUCTION_NODE) {
- $r .= qq'<?@{[htescape ($child->target)]}?>
';
- $r .= '- @{[htescape ($child->data)]}
';
+ $r .= qq'<?@{[htescape ($child->target)]}
@{[htescape ($child->data)]}
?>
';
} else {
- $r .= qq'- @{[$child->node_type]} @{[htescape ($child->node_name)]}
'; # error
+ $r .= qq'- @{[$child->node_type]} @{[htescape ($child->node_name)]}
'; # error
}
}
@@ -319,4 +393,4 @@
=cut
-## $Date: 2007/06/27 12:35:24 $
+## $Date: 2007/06/30 08:26:08 $