| 31 |
print STDOUT "#errors\n"; |
print STDOUT "#errors\n"; |
| 32 |
|
|
| 33 |
my $onerror = sub { |
my $onerror = sub { |
| 34 |
print STDOUT "0,0,", $_[0], "\n"; |
my (%opt) = @_; |
| 35 |
|
print STDOUT "$opt{line},$opt{column},$opt{type}\n"; |
| 36 |
}; |
}; |
| 37 |
|
|
| 38 |
my $doc = Whatpm::HTML->parse_string |
my $doc = Whatpm::HTML->parse_string |
| 47 |
$out = test_serialize ($doc); |
$out = test_serialize ($doc); |
| 48 |
} |
} |
| 49 |
print STDOUT Encode::encode ('utf-8', $$out); |
print STDOUT Encode::encode ('utf-8', $$out); |
| 50 |
|
print STDOUT "\n"; |
| 51 |
|
|
| 52 |
|
if ($http->parameter ('dom5')) { |
| 53 |
|
require Whatpm::ContentChecker; |
| 54 |
|
print STDOUT "#domerrors\n"; |
| 55 |
|
my $docel = $doc->document_element; |
| 56 |
|
my $docel_nsuri = $docel->namespace_uri; |
| 57 |
|
if (defined $docel_nsuri and |
| 58 |
|
$docel_nsuri eq q<http://www.w3.org/1999/xhtml> and |
| 59 |
|
$docel->manakai_local_name eq 'html') { |
| 60 |
|
# |
| 61 |
|
} else { |
| 62 |
|
print STDOUT get_node_path ($docel) . ";element not allowed\n"; |
| 63 |
|
} |
| 64 |
|
my $cc = Whatpm::ContentChecker->new; |
| 65 |
|
$cc->check_element ($docel, sub { |
| 66 |
|
my %opt = @_; |
| 67 |
|
print STDOUT get_node_path ($opt{node}) . ';' . $opt{type} . "\n"; |
| 68 |
|
}); |
| 69 |
|
} |
| 70 |
} else { |
} else { |
| 71 |
print STDOUT "Status: 404 Not Found\nContent-Type: text/plain; charset=us-ascii\n\n404"; |
print STDOUT "Status: 404 Not Found\nContent-Type: text/plain; charset=us-ascii\n\n404"; |
| 72 |
} |
} |
| 105 |
|
|
| 106 |
return \$r; |
return \$r; |
| 107 |
} # test_serialize |
} # test_serialize |
| 108 |
|
|
| 109 |
|
sub get_node_path ($) { |
| 110 |
|
my $node = shift; |
| 111 |
|
my @r; |
| 112 |
|
while (defined $node) { |
| 113 |
|
my $rs; |
| 114 |
|
if ($node->node_type == 1) { |
| 115 |
|
$rs = $node->manakai_local_name; |
| 116 |
|
$node = $node->parent_node; |
| 117 |
|
} elsif ($node->node_type == 2) { |
| 118 |
|
$rs = '@' . $node->manakai_local_name; |
| 119 |
|
$node = $node->owner_element; |
| 120 |
|
} elsif ($node->node_type == 3) { |
| 121 |
|
$rs = '"' . $node->data . '"'; |
| 122 |
|
$node = $node->parent_node; |
| 123 |
|
} elsif ($node->node_type == 9) { |
| 124 |
|
$rs = ''; |
| 125 |
|
$node = $node->parent_node; |
| 126 |
|
} else { |
| 127 |
|
$rs = '#' . $node->node_type; |
| 128 |
|
$node = $node->parent_node; |
| 129 |
|
} |
| 130 |
|
unshift @r, $rs; |
| 131 |
|
} |
| 132 |
|
return join '/', @r; |
| 133 |
|
} # get_node_path |
| 134 |
|
|
| 135 |
|
=head1 AUTHOR |
| 136 |
|
|
| 137 |
|
Wakaba <w@suika.fam.cx>. |
| 138 |
|
|
| 139 |
|
=head1 LICENSE |
| 140 |
|
|
| 141 |
|
Copyright 2007 Wakaba <w@suika.fam.cx> |
| 142 |
|
|
| 143 |
|
This library is free software; you can redistribute it |
| 144 |
|
and/or modify it under the same terms as Perl itself. |
| 145 |
|
|
| 146 |
|
=cut |
| 147 |
|
|
| 148 |
|
## $Date$ |