Filename | /usr/share/perl5/XML/SAX/Expat.pm |
Statements | Executed 6040169 statements in 27.5s |
Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
---|---|---|---|---|---|
185299 | 1 | 1 | 13.4s | 34.3s | _handle_start | XML::SAX::Expat::
607406 | 1 | 1 | 8.06s | 22.3s | _handle_char | XML::SAX::Expat::
185299 | 1 | 1 | 6.05s | 19.8s | _handle_end | XML::SAX::Expat::
5000 | 1 | 1 | 297ms | 2.07s | _create_parser | XML::SAX::Expat::
15000 | 2 | 1 | 193ms | 266ms | supported_features | XML::SAX::Expat::
5000 | 1 | 1 | 179ms | 88.5s | _parse_string | XML::SAX::Expat::
5000 | 1 | 1 | 70.8ms | 354ms | _handle_start_document | XML::SAX::Expat::
5000 | 1 | 1 | 68.5ms | 365ms | _handle_final | XML::SAX::Expat::
5000 | 1 | 1 | 37.4ms | 37.4ms | _cleanup | XML::SAX::Expat::
5000 | 1 | 1 | 17.1ms | 17.1ms | _handle_init | XML::SAX::Expat::
1 | 1 | 1 | 2.54ms | 3.43ms | BEGIN@10 | XML::SAX::Expat::
1 | 1 | 1 | 2.04ms | 9.19ms | BEGIN@11 | XML::SAX::Expat::
1 | 1 | 1 | 24µs | 30µs | BEGIN@8 | XML::SAX::Expat::
1 | 1 | 1 | 18µs | 60µs | BEGIN@13 | XML::SAX::Expat::
1 | 1 | 1 | 15µs | 119µs | BEGIN@9 | XML::SAX::Expat::
0 | 0 | 0 | 0s | 0s | _handle_attr_decl | XML::SAX::Expat::
0 | 0 | 0 | 0s | 0s | _handle_comment | XML::SAX::Expat::
0 | 0 | 0 | 0s | 0s | _handle_element_decl | XML::SAX::Expat::
0 | 0 | 0 | 0s | 0s | _handle_end_cdata | XML::SAX::Expat::
0 | 0 | 0 | 0s | 0s | _handle_end_doctype | XML::SAX::Expat::
0 | 0 | 0 | 0s | 0s | _handle_entity_decl | XML::SAX::Expat::
0 | 0 | 0 | 0s | 0s | _handle_notation_decl | XML::SAX::Expat::
0 | 0 | 0 | 0s | 0s | _handle_proc | XML::SAX::Expat::
0 | 0 | 0 | 0s | 0s | _handle_start_cdata | XML::SAX::Expat::
0 | 0 | 0 | 0s | 0s | _handle_start_doctype | XML::SAX::Expat::
0 | 0 | 0 | 0s | 0s | _handle_unparsed_entity | XML::SAX::Expat::
0 | 0 | 0 | 0s | 0s | _handle_xml_decl | XML::SAX::Expat::
0 | 0 | 0 | 0s | 0s | _parse_bytestream | XML::SAX::Expat::
0 | 0 | 0 | 0s | 0s | _parse_characterstream | XML::SAX::Expat::
0 | 0 | 0 | 0s | 0s | _parse_systemid | XML::SAX::Expat::
Line | State ments |
Time on line |
Calls | Time in subs |
Code |
---|---|---|---|---|---|
1 | |||||
2 | ### | ||||
3 | # XML::SAX::Expat - SAX2 Driver for Expat (XML::Parser) | ||||
4 | # Originally by Robin Berjon | ||||
5 | ### | ||||
6 | |||||
7 | package XML::SAX::Expat; | ||||
8 | 3 | 52µs | 2 | 36µs | # spent 30µs (24+6) within XML::SAX::Expat::BEGIN@8 which was called:
# once (24µs+6µs) by XML::SAX::ParserFactory::BEGIN@1 at line 8 # spent 30µs making 1 call to XML::SAX::Expat::BEGIN@8
# spent 6µs making 1 call to strict::import |
9 | 3 | 49µs | 2 | 223µs | # spent 119µs (15+104) within XML::SAX::Expat::BEGIN@9 which was called:
# once (15µs+104µs) by XML::SAX::ParserFactory::BEGIN@1 at line 9 # spent 119µs making 1 call to XML::SAX::Expat::BEGIN@9
# spent 104µs making 1 call to base::import |
10 | 3 | 161µs | 1 | 3.43ms | # spent 3.43ms (2.54+893µs) within XML::SAX::Expat::BEGIN@10 which was called:
# once (2.54ms+893µs) by XML::SAX::ParserFactory::BEGIN@1 at line 10 # spent 3.43ms making 1 call to XML::SAX::Expat::BEGIN@10 |
11 | 3 | 162µs | 1 | 9.19ms | # spent 9.19ms (2.04+7.15) within XML::SAX::Expat::BEGIN@11 which was called:
# once (2.04ms+7.15ms) by XML::SAX::ParserFactory::BEGIN@1 at line 11 # spent 9.19ms making 1 call to XML::SAX::Expat::BEGIN@11 |
12 | |||||
13 | 3 | 2.47ms | 2 | 102µs | # spent 60µs (18+42) within XML::SAX::Expat::BEGIN@13 which was called:
# once (18µs+42µs) by XML::SAX::ParserFactory::BEGIN@1 at line 13 # spent 60µs making 1 call to XML::SAX::Expat::BEGIN@13
# spent 42µs making 1 call to vars::import |
14 | 1 | 2µs | $VERSION = '0.40'; | ||
15 | |||||
16 | |||||
17 | #,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,# | ||||
18 | #`,`, Variations on parse `,`,`,`,`,`,`,`,`,`,`,`,`,`,`,`,`,`,`,`,`,# | ||||
19 | #```````````````````````````````````````````````````````````````````# | ||||
20 | |||||
21 | #-------------------------------------------------------------------# | ||||
22 | # CharacterStream | ||||
23 | #-------------------------------------------------------------------# | ||||
24 | sub _parse_characterstream { | ||||
25 | my $p = shift; | ||||
26 | my $xml = shift; | ||||
27 | my $opt = shift; | ||||
28 | |||||
29 | my $expat = $p->_create_parser($opt); | ||||
30 | my $result = $expat->parse($xml); | ||||
31 | $p->_cleanup; | ||||
32 | return $result; | ||||
33 | } | ||||
34 | #-------------------------------------------------------------------# | ||||
35 | |||||
36 | #-------------------------------------------------------------------# | ||||
37 | # ByteStream | ||||
38 | #-------------------------------------------------------------------# | ||||
39 | sub _parse_bytestream { | ||||
40 | my $p = shift; | ||||
41 | my $xml = shift; | ||||
42 | my $opt = shift; | ||||
43 | |||||
44 | my $expat = $p->_create_parser($opt); | ||||
45 | my $result = $expat->parse($xml); | ||||
46 | $p->_cleanup; | ||||
47 | return $result; | ||||
48 | } | ||||
49 | #-------------------------------------------------------------------# | ||||
50 | |||||
51 | #-------------------------------------------------------------------# | ||||
52 | # String | ||||
53 | #-------------------------------------------------------------------# | ||||
54 | # spent 88.5s (179ms+88.3) within XML::SAX::Expat::_parse_string which was called 5000 times, avg 17.7ms/call:
# 5000 times (179ms+88.3s) by XML::SAX::Base::parse at line 2602 of XML/SAX/Base.pm, avg 17.7ms/call | ||||
55 | 35000 | 171ms | my $p = shift; | ||
56 | my $xml = shift; | ||||
57 | my $opt = shift; | ||||
58 | |||||
59 | 5000 | 2.07s | my $expat = $p->_create_parser($opt);
# spent 2.07s making 5000 calls to XML::SAX::Expat::_create_parser, avg 413µs/call | ||
60 | 1 | 45.6ms | 10000 | 86.4s | my $result = $expat->parse($xml);
# spent 86.2s making 5000 calls to XML::Parser::parse, avg 17.2ms/call
# spent 127ms making 5000 calls to XML::Parser::Expat::DESTROY, avg 25µs/call |
61 | 5000 | 37.4ms | $p->_cleanup;
# spent 37.4ms making 5000 calls to XML::SAX::Expat::_cleanup, avg 7µs/call | ||
62 | return $result; | ||||
63 | } | ||||
64 | #-------------------------------------------------------------------# | ||||
65 | |||||
66 | #-------------------------------------------------------------------# | ||||
67 | # SystemId | ||||
68 | #-------------------------------------------------------------------# | ||||
69 | sub _parse_systemid { | ||||
70 | my $p = shift; | ||||
71 | my $xml = shift; | ||||
72 | my $opt = shift; | ||||
73 | |||||
74 | my $expat = $p->_create_parser($opt); | ||||
75 | my $result = $expat->parsefile($xml); | ||||
76 | $p->_cleanup; | ||||
77 | return $result; | ||||
78 | } | ||||
79 | #-------------------------------------------------------------------# | ||||
80 | |||||
81 | |||||
82 | #-------------------------------------------------------------------# | ||||
83 | # $p->_create_parser(\%options) | ||||
84 | #-------------------------------------------------------------------# | ||||
85 | # spent 2.07s (297ms+1.77) within XML::SAX::Expat::_create_parser which was called 5000 times, avg 413µs/call:
# 5000 times (297ms+1.77s) by XML::SAX::Expat::_parse_string at line 59, avg 413µs/call | ||||
86 | 70000 | 276ms | my $self = shift; | ||
87 | my $opt = shift; | ||||
88 | |||||
89 | die "ParserReference: parser instance ($self) already parsing\n" | ||||
90 | if $self->{_InParse}; | ||||
91 | |||||
92 | my $featUri = 'http://xml.org/sax/features/'; | ||||
93 | 10000 | 602ms | my $ppe = ($self->get_feature($featUri . 'external-general-entities') or
# spent 602ms making 10000 calls to XML::SAX::Base::get_feature, avg 60µs/call | ||
94 | $self->get_feature($featUri . 'external-parameter-entities') ) ? 1 : 0; | ||||
95 | |||||
96 | 5000 | 273ms | my $expat = XML::Parser->new( ParseParamEnt => $ppe );
# spent 273ms making 5000 calls to XML::Parser::new, avg 55µs/call | ||
97 | $expat->{__XSE} = $self; | ||||
98 | 5000 | 791ms | $expat->setHandlers(
# spent 791ms making 5000 calls to XML::Parser::setHandlers, avg 158µs/call | ||
99 | Init => \&_handle_init, | ||||
100 | Final => \&_handle_final, | ||||
101 | Start => \&_handle_start, | ||||
102 | End => \&_handle_end, | ||||
103 | Char => \&_handle_char, | ||||
104 | Comment => \&_handle_comment, | ||||
105 | Proc => \&_handle_proc, | ||||
106 | CdataStart => \&_handle_start_cdata, | ||||
107 | CdataEnd => \&_handle_end_cdata, | ||||
108 | Unparsed => \&_handle_unparsed_entity, | ||||
109 | Notation => \&_handle_notation_decl, | ||||
110 | #ExternEnt | ||||
111 | #ExternEntFin | ||||
112 | Entity => \&_handle_entity_decl, | ||||
113 | Element => \&_handle_element_decl, | ||||
114 | Attlist => \&_handle_attr_decl, | ||||
115 | Doctype => \&_handle_start_doctype, | ||||
116 | DoctypeFin => \&_handle_end_doctype, | ||||
117 | XMLDecl => \&_handle_xml_decl, | ||||
118 | ); | ||||
119 | |||||
120 | $self->{_InParse} = 1; | ||||
121 | $self->{_NodeStack} = []; | ||||
122 | $self->{_NSStack} = []; | ||||
123 | 5000 | 103ms | $self->{_NSHelper} = XML::NamespaceSupport->new({xmlns => 1});
# spent 103ms making 5000 calls to XML::NamespaceSupport::new, avg 21µs/call | ||
124 | $self->{_started} = 0; | ||||
125 | |||||
126 | return $expat; | ||||
127 | } | ||||
128 | #-------------------------------------------------------------------# | ||||
129 | |||||
130 | |||||
131 | #-------------------------------------------------------------------# | ||||
132 | # $p->_cleanup | ||||
133 | #-------------------------------------------------------------------# | ||||
134 | # spent 37.4ms within XML::SAX::Expat::_cleanup which was called 5000 times, avg 7µs/call:
# 5000 times (37.4ms+0s) by XML::SAX::Expat::_parse_string at line 61, avg 7µs/call | ||||
135 | 15000 | 41.2ms | my $self = shift; | ||
136 | |||||
137 | $self->{_InParse} = 0; | ||||
138 | delete $self->{_NodeStack}; | ||||
139 | } | ||||
140 | #-------------------------------------------------------------------# | ||||
141 | |||||
142 | |||||
143 | |||||
144 | #,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,# | ||||
145 | #`,`, Expat Handlers ,`,`,`,`,`,`,`,`,`,`,`,`,`,`,`,`,`,`,`,`,`,`,`,# | ||||
146 | #```````````````````````````````````````````````````````````````````# | ||||
147 | |||||
148 | #-------------------------------------------------------------------# | ||||
149 | # _handle_init | ||||
150 | #-------------------------------------------------------------------# | ||||
151 | 5000 | 20.7ms | # spent 17.1ms within XML::SAX::Expat::_handle_init which was called 5000 times, avg 3µs/call:
# 5000 times (17.1ms+0s) by XML::Parser::parse at line 181 of XML/Parser.pm, avg 3µs/call | ||
152 | #my $self = shift()->{__XSE}; | ||||
153 | |||||
154 | #my $document = {}; | ||||
155 | #push @{$self->{_NodeStack}}, $document; | ||||
156 | #$self->SUPER::start_document($document); | ||||
157 | } | ||||
158 | #-------------------------------------------------------------------# | ||||
159 | |||||
160 | #-------------------------------------------------------------------# | ||||
161 | # _handle_final | ||||
162 | #-------------------------------------------------------------------# | ||||
163 | # spent 365ms (68.5+297) within XML::SAX::Expat::_handle_final which was called 5000 times, avg 73µs/call:
# 5000 times (68.5ms+297ms) by XML::Parser::parse at line 200 of XML/Parser.pm, avg 73µs/call | ||||
164 | 10000 | 67.1ms | my $self = shift()->{__XSE}; | ||
165 | |||||
166 | #my $document = pop @{$self->{_NodeStack}}; | ||||
167 | 5000 | 297ms | return $self->SUPER::end_document({});
# spent 297ms making 5000 calls to XML::SAX::Base::end_document, avg 59µs/call | ||
168 | } | ||||
169 | #-------------------------------------------------------------------# | ||||
170 | |||||
171 | #-------------------------------------------------------------------# | ||||
172 | # _handle_start | ||||
173 | #-------------------------------------------------------------------# | ||||
174 | # spent 34.3s (13.4+20.9) within XML::SAX::Expat::_handle_start which was called 185299 times, avg 185µs/call:
# 185299 times (13.4s+20.9s) by XML::Parser::Expat::ParseString at line 474 of XML/Parser/Expat.pm, avg 185µs/call | ||||
175 | 3368247 | 12.8s | my $self = shift()->{__XSE}; | ||
176 | my $e_name = shift; | ||||
177 | my %attr = @_; | ||||
178 | |||||
179 | # start_document data | ||||
180 | 5000 | 354ms | $self->_handle_start_document({}) unless $self->{_started};
# spent 354ms making 5000 calls to XML::SAX::Expat::_handle_start_document, avg 71µs/call | ||
181 | |||||
182 | # take care of namespaces | ||||
183 | my $nsh = $self->{_NSHelper}; | ||||
184 | 185299 | 1.59s | $nsh->push_context;
# spent 1.59s making 185299 calls to XML::NamespaceSupport::push_context, avg 9µs/call | ||
185 | my @new_ns; | ||||
186 | for my $k (grep !index($_, 'xmlns'), keys %attr) { | ||||
187 | $k =~ m/^xmlns(:(.*))?$/; | ||||
188 | my $prefix = $2 || ''; | ||||
189 | $nsh->declare_prefix($prefix, $attr{$k}); | ||||
190 | my $ns = { | ||||
191 | Prefix => $prefix, | ||||
192 | NamespaceURI => $attr{$k}, | ||||
193 | }; | ||||
194 | push @new_ns, $ns; | ||||
195 | $self->SUPER::start_prefix_mapping($ns); | ||||
196 | } | ||||
197 | push @{$self->{_NSStack}}, \@new_ns; | ||||
198 | |||||
199 | |||||
200 | # create the attributes | ||||
201 | my %saxattr; | ||||
202 | 294381 | 8.28s | map {
# spent 8.28s making 294381 calls to XML::NamespaceSupport::process_attribute_name, avg 28µs/call | ||
203 | my ($ns,$prefix,$lname) = $nsh->process_attribute_name($_); | ||||
204 | $saxattr{'{' . ($ns || '') . '}' . $lname} = { | ||||
205 | Name => $_, | ||||
206 | LocalName => $lname || '', | ||||
207 | Prefix => $prefix || '', | ||||
208 | Value => $attr{$_}, | ||||
209 | NamespaceURI => $ns || '', | ||||
210 | }; | ||||
211 | } keys %attr; | ||||
212 | |||||
213 | |||||
214 | # now the element | ||||
215 | 185299 | 5.14s | my ($ns,$prefix,$lname) = $nsh->process_element_name($e_name);
# spent 5.14s making 185299 calls to XML::NamespaceSupport::process_element_name, avg 28µs/call | ||
216 | my $element = { | ||||
217 | Name => $e_name, | ||||
218 | LocalName => $lname || '', | ||||
219 | Prefix => $prefix || '', | ||||
220 | NamespaceURI => $ns || '', | ||||
221 | Attributes => \%saxattr, | ||||
222 | }; | ||||
223 | |||||
224 | push @{$self->{_NodeStack}}, $element; | ||||
225 | 185299 | 5.54s | $self->SUPER::start_element($element);
# spent 5.54s making 185299 calls to XML::SAX::Base::start_element, avg 30µs/call | ||
226 | } | ||||
227 | #-------------------------------------------------------------------# | ||||
228 | |||||
229 | #-------------------------------------------------------------------# | ||||
230 | # _handle_end | ||||
231 | #-------------------------------------------------------------------# | ||||
232 | # spent 19.8s (6.05+13.8) within XML::SAX::Expat::_handle_end which was called 185299 times, avg 107µs/call:
# 185299 times (6.05s+13.8s) by XML::Parser::Expat::ParseString at line 474 of XML/Parser/Expat.pm, avg 107µs/call | ||||
233 | 1297093 | 5.84s | my $self = shift()->{__XSE}; | ||
234 | |||||
235 | my %element = %{pop @{$self->{_NodeStack}}}; | ||||
236 | delete $element{Attributes}; | ||||
237 | 185299 | 12.7s | $self->SUPER::end_element(\%element);
# spent 12.7s making 185299 calls to XML::SAX::Base::end_element, avg 68µs/call | ||
238 | |||||
239 | my $prev_ns = pop @{$self->{_NSStack}}; | ||||
240 | for my $ns (@$prev_ns) { | ||||
241 | $self->SUPER::end_prefix_mapping( { %$ns } ); | ||||
242 | } | ||||
243 | 185299 | 1.12s | $self->{_NSHelper}->pop_context;
# spent 1.12s making 185299 calls to XML::NamespaceSupport::pop_context, avg 6µs/call | ||
244 | } | ||||
245 | #-------------------------------------------------------------------# | ||||
246 | |||||
247 | #-------------------------------------------------------------------# | ||||
248 | # _handle_char | ||||
249 | #-------------------------------------------------------------------# | ||||
250 | # spent 22.3s (8.06+14.3) within XML::SAX::Expat::_handle_char which was called 607406 times, avg 37µs/call:
# 607406 times (8.06s+14.3s) by XML::Parser::Expat::ParseString at line 474 of XML/Parser/Expat.pm, avg 37µs/call | ||||
251 | 1214812 | 8.00s | $_[0]->{__XSE}->_handle_start_document({}) unless $_[0]->{__XSE}->{_started}; | ||
252 | 607406 | 14.3s | $_[0]->{__XSE}->SUPER::characters({ Data => $_[1] });
# spent 14.3s making 607406 calls to XML::SAX::Base::characters, avg 24µs/call | ||
253 | } | ||||
254 | #-------------------------------------------------------------------# | ||||
255 | |||||
256 | #-------------------------------------------------------------------# | ||||
257 | # _handle_comment | ||||
258 | #-------------------------------------------------------------------# | ||||
259 | sub _handle_comment { | ||||
260 | $_[0]->{__XSE}->_handle_start_document({}) unless $_[0]->{__XSE}->{_started}; | ||||
261 | $_[0]->{__XSE}->SUPER::comment({ Data => $_[1] }); | ||||
262 | } | ||||
263 | #-------------------------------------------------------------------# | ||||
264 | |||||
265 | #-------------------------------------------------------------------# | ||||
266 | # _handle_proc | ||||
267 | #-------------------------------------------------------------------# | ||||
268 | sub _handle_proc { | ||||
269 | $_[0]->{__XSE}->_handle_start_document({}) unless $_[0]->{__XSE}->{_started}; | ||||
270 | $_[0]->{__XSE}->SUPER::processing_instruction({ Target => $_[1], Data => $_[2] }); | ||||
271 | } | ||||
272 | #-------------------------------------------------------------------# | ||||
273 | |||||
274 | #-------------------------------------------------------------------# | ||||
275 | # _handle_start_cdata | ||||
276 | #-------------------------------------------------------------------# | ||||
277 | sub _handle_start_cdata { | ||||
278 | $_[0]->{__XSE}->SUPER::start_cdata( {} ); | ||||
279 | } | ||||
280 | #-------------------------------------------------------------------# | ||||
281 | |||||
282 | #-------------------------------------------------------------------# | ||||
283 | # _handle_end_cdata | ||||
284 | #-------------------------------------------------------------------# | ||||
285 | sub _handle_end_cdata { | ||||
286 | $_[0]->{__XSE}->SUPER::end_cdata( {} ); | ||||
287 | } | ||||
288 | #-------------------------------------------------------------------# | ||||
289 | |||||
290 | #-------------------------------------------------------------------# | ||||
291 | # _handle_xml_decl | ||||
292 | #-------------------------------------------------------------------# | ||||
293 | sub _handle_xml_decl { | ||||
294 | my $self = shift()->{__XSE}; | ||||
295 | my $version = shift; | ||||
296 | my $encoding = shift; | ||||
297 | my $standalone = shift; | ||||
298 | |||||
299 | if (not defined $standalone) { $standalone = ''; } | ||||
300 | elsif ($standalone) { $standalone = 'yes'; } | ||||
301 | else { $standalone = 'no'; } | ||||
302 | my $xd = { | ||||
303 | Version => $version, | ||||
304 | Encoding => $encoding, | ||||
305 | Standalone => $standalone, | ||||
306 | }; | ||||
307 | #$self->SUPER::xml_decl($xd); | ||||
308 | $self->_handle_start_document($xd); | ||||
309 | } | ||||
310 | #-------------------------------------------------------------------# | ||||
311 | |||||
312 | #-------------------------------------------------------------------# | ||||
313 | # _handle_notation_decl | ||||
314 | #-------------------------------------------------------------------# | ||||
315 | sub _handle_notation_decl { | ||||
316 | my $self = shift()->{__XSE}; | ||||
317 | my $notation = shift; | ||||
318 | shift; | ||||
319 | my $system = shift; | ||||
320 | my $public = shift; | ||||
321 | |||||
322 | my $not = { | ||||
323 | Name => $notation, | ||||
324 | PublicId => $public, | ||||
325 | SystemId => $system, | ||||
326 | }; | ||||
327 | $self->SUPER::notation_decl($not); | ||||
328 | } | ||||
329 | #-------------------------------------------------------------------# | ||||
330 | |||||
331 | #-------------------------------------------------------------------# | ||||
332 | # _handle_unparsed_entity | ||||
333 | #-------------------------------------------------------------------# | ||||
334 | sub _handle_unparsed_entity { | ||||
335 | my $self = shift()->{__XSE}; | ||||
336 | my $name = shift; | ||||
337 | my $system = shift; | ||||
338 | my $public = shift; | ||||
339 | my $notation = shift; | ||||
340 | |||||
341 | my $ue = { | ||||
342 | Name => $name, | ||||
343 | PublicId => $public, | ||||
344 | SystemId => $system, | ||||
345 | Notation => $notation, | ||||
346 | }; | ||||
347 | $self->SUPER::unparsed_entity_decl($ue); | ||||
348 | } | ||||
349 | #-------------------------------------------------------------------# | ||||
350 | |||||
351 | #-------------------------------------------------------------------# | ||||
352 | # _handle_element_decl | ||||
353 | #-------------------------------------------------------------------# | ||||
354 | sub _handle_element_decl { | ||||
355 | $_[0]->{__XSE}->SUPER::element_decl({ Name => $_[1], Model => "$_[2]" }); | ||||
356 | } | ||||
357 | #-------------------------------------------------------------------# | ||||
358 | |||||
359 | |||||
360 | #-------------------------------------------------------------------# | ||||
361 | # _handle_attr_decl | ||||
362 | #-------------------------------------------------------------------# | ||||
363 | sub _handle_attr_decl { | ||||
364 | my $self = shift()->{__XSE}; | ||||
365 | my $ename = shift; | ||||
366 | my $aname = shift; | ||||
367 | my $type = shift; | ||||
368 | my $default = shift; | ||||
369 | my $fixed = shift; | ||||
370 | |||||
371 | my ($vd, $value); | ||||
372 | if ($fixed) { | ||||
373 | $vd = '#FIXED'; | ||||
374 | $default =~ s/^(?:"|')//; #" | ||||
375 | $default =~ s/(?:"|')$//; #" | ||||
376 | $value = $default; | ||||
377 | } | ||||
378 | else { | ||||
379 | if ($default =~ m/^#/) { | ||||
380 | $vd = $default; | ||||
381 | $value = ''; | ||||
382 | } | ||||
383 | else { | ||||
384 | $vd = ''; # maybe there's a default ? | ||||
385 | $default =~ s/^(?:"|')//; #" | ||||
386 | $default =~ s/(?:"|')$//; #" | ||||
387 | $value = $default; | ||||
388 | } | ||||
389 | } | ||||
390 | |||||
391 | my $at = { | ||||
392 | eName => $ename, | ||||
393 | aName => $aname, | ||||
394 | Type => $type, | ||||
395 | ValueDefault => $vd, | ||||
396 | Value => $value, | ||||
397 | }; | ||||
398 | $self->SUPER::attribute_decl($at); | ||||
399 | } | ||||
400 | #-------------------------------------------------------------------# | ||||
401 | |||||
402 | #-------------------------------------------------------------------# | ||||
403 | # _handle_entity_decl | ||||
404 | #-------------------------------------------------------------------# | ||||
405 | sub _handle_entity_decl { | ||||
406 | my $self = shift()->{__XSE}; | ||||
407 | my $name = shift; | ||||
408 | my $val = shift; | ||||
409 | my $sys = shift; | ||||
410 | my $pub = shift; | ||||
411 | my $ndata = shift; | ||||
412 | my $isprm = shift; | ||||
413 | |||||
414 | # deal with param ents | ||||
415 | if ($isprm) { | ||||
416 | $name = '%' . $name; | ||||
417 | } | ||||
418 | |||||
419 | # int vs ext | ||||
420 | if ($val) { | ||||
421 | my $ent = { | ||||
422 | Name => $name, | ||||
423 | Value => $val, | ||||
424 | }; | ||||
425 | $self->SUPER::internal_entity_decl($ent); | ||||
426 | } | ||||
427 | else { | ||||
428 | my $ent = { | ||||
429 | Name => $name, | ||||
430 | PublicId => $pub || '', | ||||
431 | SystemId => $sys, | ||||
432 | }; | ||||
433 | $self->SUPER::external_entity_decl($ent); | ||||
434 | } | ||||
435 | } | ||||
436 | #-------------------------------------------------------------------# | ||||
437 | |||||
438 | |||||
439 | #-------------------------------------------------------------------# | ||||
440 | # _handle_start_doctype | ||||
441 | #-------------------------------------------------------------------# | ||||
442 | sub _handle_start_doctype { | ||||
443 | my $self = shift()->{__XSE}; | ||||
444 | my $name = shift; | ||||
445 | my $sys = shift; | ||||
446 | my $pub = shift; | ||||
447 | |||||
448 | $self->_handle_start_document({}) unless $self->{_started}; | ||||
449 | |||||
450 | my $dtd = { | ||||
451 | Name => $name, | ||||
452 | SystemId => $sys, | ||||
453 | PublicId => $pub, | ||||
454 | }; | ||||
455 | $self->SUPER::start_dtd($dtd); | ||||
456 | } | ||||
457 | #-------------------------------------------------------------------# | ||||
458 | |||||
459 | #-------------------------------------------------------------------# | ||||
460 | # _handle_end_doctype | ||||
461 | #-------------------------------------------------------------------# | ||||
462 | sub _handle_end_doctype { | ||||
463 | $_[0]->{__XSE}->SUPER::end_dtd( {} ); | ||||
464 | } | ||||
465 | #-------------------------------------------------------------------# | ||||
466 | |||||
467 | |||||
468 | #-------------------------------------------------------------------# | ||||
469 | # _handle_start_document | ||||
470 | #-------------------------------------------------------------------# | ||||
471 | # spent 354ms (70.8+283) within XML::SAX::Expat::_handle_start_document which was called 5000 times, avg 71µs/call:
# 5000 times (70.8ms+283ms) by XML::SAX::Expat::_handle_start at line 180, avg 71µs/call | ||||
472 | 10000 | 71.2ms | 5000 | 283ms | $_[0]->SUPER::start_document($_[1]);
# spent 283ms making 5000 calls to XML::SAX::Base::start_document, avg 57µs/call |
473 | $_[0]->{_started} = 1; | ||||
474 | } | ||||
475 | #-------------------------------------------------------------------# | ||||
476 | |||||
477 | |||||
478 | #-------------------------------------------------------------------# | ||||
479 | # supported_features | ||||
480 | #-------------------------------------------------------------------# | ||||
481 | # spent 266ms (193+73.8) within XML::SAX::Expat::supported_features which was called 15000 times, avg 18µs/call:
# 10000 times (120ms+46.6ms) by XML::SAX::Base::get_feature at line 2710 of XML/SAX/Base.pm, avg 17µs/call
# 5000 times (72.2ms+27.2ms) by XML::SAX::Base::set_feature at line 2740 of XML/SAX/Base.pm, avg 20µs/call | ||||
482 | return ( | ||||
483 | 15000 | 181ms | 15000 | 73.8ms | $_[0]->SUPER::supported_features,
# spent 73.8ms making 15000 calls to XML::SAX::Base::supported_features, avg 5µs/call |
484 | 'http://xml.org/sax/features/external-general-entities', | ||||
485 | 'http://xml.org/sax/features/external-parameter-entities', | ||||
486 | ); | ||||
487 | } | ||||
488 | #-------------------------------------------------------------------# | ||||
489 | |||||
490 | |||||
491 | |||||
492 | |||||
493 | |||||
494 | #,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,# | ||||
495 | #`,`, Private Helpers `,`,`,`,`,`,`,`,`,`,`,`,`,`,`,`,`,`,`,`,`,`,`,# | ||||
496 | #```````````````````````````````````````````````````````````````````# | ||||
497 | |||||
498 | #-------------------------------------------------------------------# | ||||
499 | # _create_node | ||||
500 | #-------------------------------------------------------------------# | ||||
501 | #sub _create_node { | ||||
502 | # shift; | ||||
503 | # # this may check for a factory later | ||||
504 | # return {@_}; | ||||
505 | #} | ||||
506 | #-------------------------------------------------------------------# | ||||
507 | |||||
508 | |||||
509 | 1 | 4µs | 1; | ||
510 | #,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,# | ||||
511 | #`,`, Documentation `,`,`,`,`,`,`,`,`,`,`,`,`,`,`,`,`,`,`,`,`,`,`,`,# | ||||
512 | #```````````````````````````````````````````````````````````````````# | ||||
513 | |||||
514 | =pod | ||||
515 | |||||
- - |