28 |
my $time2; |
my $time2; |
29 |
|
|
30 |
require Message::DOM::DOMImplementation; |
require Message::DOM::DOMImplementation; |
31 |
my $dom = Message::DOM::DOMImplementation->____new; |
my $dom = Message::DOM::DOMImplementation->new; |
32 |
# $| = 1; |
# $| = 1; |
33 |
my $doc; |
my $doc; |
34 |
my $el; |
my $el; |
54 |
}; |
}; |
55 |
|
|
56 |
$doc = $dom->create_document; |
$doc = $dom->create_document; |
57 |
|
$doc->manakai_is_html (1); |
58 |
$time1 = time; |
$time1 = time; |
59 |
if (length $mode[1]) { |
if (length $mode[1]) { |
60 |
$el = $doc->create_element_ns |
$el = $doc->create_element_ns |
71 |
my $out; |
my $out; |
72 |
if ($mode[2] eq 'html') { |
if ($mode[2] eq 'html') { |
73 |
$time1 = time; |
$time1 = time; |
74 |
$out = Whatpm::HTML->get_inner_html ($el || $doc); |
$out = \( ($el or $doc)->inner_html ); |
75 |
$time2 = time; |
$time2 = time; |
76 |
$time{serialize_html} = $time2 - $time1; |
$time{serialize_html} = $time2 - $time1; |
77 |
} else { # test |
} else { # test |
108 |
|
|
109 |
my $out; |
my $out; |
110 |
if ($mode[2] eq 'html') { |
if ($mode[2] eq 'html') { |
111 |
## TODO: Use XHTML serializer |
$time1 = time; |
112 |
#$out = Whatpm::HTML->get_inner_html ($doc); |
$out = \( $doc->inner_html ); ## TODO: $el case |
113 |
|
$time2 = time; |
114 |
|
$time{serialize_xml} = $time2 - $time1; |
115 |
|
} else { # test |
116 |
|
$time1 = time; |
117 |
|
$out = test_serialize ($doc); |
118 |
|
$time2 = time; |
119 |
|
$time{serialize_test} = $time2 - $time1; |
120 |
|
} |
121 |
|
print STDOUT Encode::encode ('utf-8', $$out); |
122 |
|
print STDOUT "\n"; |
123 |
|
} elsif (@mode == 3 and $mode[0] eq 'h2h' and $mode[1] eq '' and |
124 |
|
($mode[2] eq 'html' or $mode[2] eq 'test')) { |
125 |
|
print STDOUT "Content-Type: text/plain; charset=utf-8\n\n"; |
126 |
|
|
127 |
|
require Encode; |
128 |
|
$time1 = time; |
129 |
|
$s = Encode::decode ('utf-8', $s); |
130 |
|
$time2 = time; |
131 |
|
$time{decode} = $time2 - $time1; |
132 |
|
|
133 |
|
require Whatpm::H2H; |
134 |
|
$doc = $dom->create_document; |
135 |
|
Whatpm::H2H->parse_string ($s => $doc); |
136 |
|
|
137 |
|
print "#document\n"; |
138 |
|
|
139 |
|
my $out; |
140 |
|
if ($mode[2] eq 'html') { |
141 |
|
$time1 = time; |
142 |
|
$out = \( $doc->inner_html ); |
143 |
|
$time2 = time; |
144 |
|
$time{serialize_xml} = $time2 - $time1; |
145 |
} else { # test |
} else { # test |
146 |
$time1 = time; |
$time1 = time; |
147 |
$out = test_serialize ($doc); |
$out = test_serialize ($doc); |