Writer/XML.pm

filter: Statementstmt 26.3% 58 / 220 Branchbran 12.5% 8 / 64 Conditioncond 0.0% 0 / 11 MC/DCmcdc 0.0% 0 / 7 Subroutinesub 28.5% 8 / 28 Podpod 0.0% 0 / 24 totaltotal 20.9% 74 / 354 SCAR 66.7
CC
40
Cov
22%
start_element
133.0
notation_decl
20.0
attribute_decl
20.0
CRAP 788.4
↑ Summary Writer.pm »
1 package XML::SAX::Writer::XML;
2 5 $XML::SAX::Writer::XML::VERSION = '0.56';
3 5 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 5 ▶use XML::NamespaceSupport qw();
Subroutine BEGIN: called CC=1 SCAR=0.0
5 5 @XML::SAX::Writer::XML::ISA = qw(XML::SAX::Writer);
6  
7 # ABSTRACT: XML::SAX::Writer's SAX Handler
8  
9 ###
10 # Robin Berjon <robin@knowscape.com>
11 ###
12  
13  
14 #-------------------------------------------------------------------#
15 # start_document
16 #-------------------------------------------------------------------#
17 sub start_document {
18 13 ▶ my $self = shift;
Subroutine start_document: called CC=1 SCAR=0.0
Pod undocumented
19  
20 13 $self->setConverter;
21 13 $self->setEscaperRegex;
22 13 $self->setCommentEscaperRegex;
23  
24 13 $self->{NSDecl} = [];
25 13 $self->{NSHelper} = XML::NamespaceSupport->new({ xmlns => 1, fatal_errors => 0 });
26 13 $self->{NSHelper}->pushContext;
27  
28 13 $self->setConsumer;
29 }
30 #-------------------------------------------------------------------#
31  
32 #-------------------------------------------------------------------#
33 # end_document
34 #-------------------------------------------------------------------#
35 sub end_document {
36 4 ▶ my $self = shift;
Subroutine end_document: called CC=2 SCAR=7.1
Pod undocumented
37 # we may need to do a little more here
38 4 $self->{NSHelper}->popContext;
39 return $self->{Consumer}->finalize
40 4 ▶ if $self->{Consumer}->can( 'finalize' );
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"Consumer"}->can("finalize") 4 0 4
41 }
42 #-------------------------------------------------------------------#
43  
44 #-------------------------------------------------------------------#
45 # start_element
46 #-------------------------------------------------------------------#
47 sub start_element {
48 4 ▶ my $self = shift;
Subroutine start_element: called CC=17 SCAR=48.9
Pod undocumented
49 4 my $data = shift;
50 4 $self->_output_element;
51 4 my $attr = $data->{Attributes};
52  
53 # fix the namespaces and prefixes of what we're receiving, in case
54 # something is wrong
55 4 ▶ if ($data->{NamespaceURI}) {
Branch: 2 branches
BranchTrueFalseTotal
if ($data->{'NamespaceURI'}) { } 0 4 4
elsif ($data->{'Prefix'}) { } 0 4 4
56 0 ▶ my $uri = $self->{NSHelper}->getURI($data->{Prefix}) || '';
Condition0%0/2
$self->{'NSHelper'}->getURI($data->{'Prefix'}) || ''
l!l
00
MC/DC0%0/1
$self->{'NSHelper'}->getURI($data->{'Prefix'}) || ''
$self->{'NSHelper'}->getURI($data->{'Prefix'})
Truth table0%0/2
A
A= $self->{'NSHelper'}->getURI($data->{'Prefix'})
Aresult
11
00
57 0 ▶ if ($uri ne $data->{NamespaceURI}) { # ns has precedence
Branch: 1 branch
BranchTrueFalseTotal
if ($uri ne $data->{"NamespaceURI"}) 0 0 0
58 0 $data->{Prefix} = $self->{NSHelper}->getPrefix($data->{NamespaceURI}); # random, but correct
59 0 ▶ $data->{Name} = $data->{Prefix} ? "$data->{Prefix}:$data->{LocalName}" : "$data->{LocalName}";
Branch: 1 branch
BranchTrueFalseTotal
$data->{'Prefix'} ? : 0 0 0
60 }
61 }
62 elsif ($data->{Prefix}) { # we can't have a prefix and no NS
63 0 $data->{Name} = $data->{LocalName};
64 0 $data->{Prefix} = '';
65 }
66  
67 # create a hash containing the attributes so that we can ensure there is
68 # no duplication. Also, we check that ns are properly declared, that the
69 # Name is good, etc...
70 4 my %attr_hash;
71 4 for my $at (values %$attr) {
72 0 ▶ next unless length $at->{Name}; # people have trouble with autovivification
Branch: 1 branch
BranchTrueFalseTotal
unless length $at->{"Name"} 0 0 0
73 0 ▶ if ($at->{NamespaceURI}) {
Branch: 2 branches
BranchTrueFalseTotal
if ($at->{'NamespaceURI'}) { } 0 0 0
elsif ($at->{'Prefix'}) { } 0 0 0
74 0 my $uri = $self->{NSHelper}->getURI($at->{Prefix});
75 0 ▶ warn "Well formed error: prefix '$at->{Prefix}' is not bound to any URI" unless defined $uri;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $uri 0 0 0
76 0 ▶ if (defined $uri and $uri ne $at->{NamespaceURI}) { # ns has precedence
Branch: 1 branch
BranchTrueFalseTotal
if (defined $uri and $uri ne $at->{"NamespaceURI"}) 0 0 0
Condition0%0/3
defined $uri and $uri ne $at->{"NamespaceURI"}
!ll&&!rl&&r
000
MC/DC0%0/2
defined $uri and $uri ne $at->{"NamespaceURI"}
defined $uri $uri ne $at->{"NamespaceURI"}
Truth table0%0/3
A and B
A= defined $uriB= $uri ne $at->{"NamespaceURI"}
ABresult
0X0
100
111
77 0 $at->{Prefix} = $self->{NSHelper}->getPrefix($at->{NamespaceURI}); # random, but correct
78 0 ▶ $at->{Name} = $at->{Prefix} ? "$at->{Prefix}:$at->{LocalName}" : "$at->{LocalName}";
Branch: 1 branch
BranchTrueFalseTotal
$at->{'Prefix'} ? : 0 0 0
79 }
80 }
81 elsif ($at->{Prefix}) { # we can't have a prefix and no NS
82 0 $at->{Name} = $at->{LocalName};
83 0 $at->{Prefix} = '';
84 }
85 0 $attr_hash{$at->{Name}} = $at->{Value};
86 }
87  
88 4 for my $nd (@{$self->{NSDecl}}) {
89 0 ▶ if ($nd->{Prefix}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($nd->{'Prefix'}) { } 0 0 0
90 0 $attr_hash{'xmlns:' . $nd->{Prefix}} = $nd->{NamespaceURI};
91 }
92 else {
93 0 $attr_hash{'xmlns'} = $nd->{NamespaceURI};
94 }
95 }
96 4 $self->{NSDecl} = [];
97  
98 # build a string from what we have, and buffer it
99 4 my $el = '<' . $data->{Name};
100 4 for my $k (keys %attr_hash) {
101 0 $el .= ' ' . $k . qq[=$self->{QuoteCharacter}] . $self->escape($attr_hash{$k}) . qq[$self->{QuoteCharacter}];
102 }
103  
104 4 $self->{BufferElement} = $el;
105 4 $self->{NSHelper}->pushContext;
106 }
107 #-------------------------------------------------------------------#
108  
109 #-------------------------------------------------------------------#
110 # end_element
111 #-------------------------------------------------------------------#
112 sub end_element {
113 4 ▶ my $self = shift;
Subroutine end_element: called CC=2 SCAR=6.9
Pod undocumented
114 4 my $data = shift;
115  
116 4 my $el;
117 4 ▶ if ($self->{BufferElement}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'BufferElement'}) { } 2 2 4
118 2 $el = $self->{BufferElement} . ' />';
119 }
120 else {
121 2 $el = '</' . $data->{Name} . '>';
122 }
123 4 $el = $self->safeConvert($el);
124 4 $self->{Consumer}->output($el);
125 4 $self->{NSHelper}->popContext;
126 4 $self->{BufferElement} = '';
127 }
128 #-------------------------------------------------------------------#
129  
130 #-------------------------------------------------------------------#
131 # characters
132 #-------------------------------------------------------------------#
133 sub characters {
134 2 ▶ my $self = shift;
Subroutine characters: called CC=2 SCAR=7.1
Pod undocumented
135 2 my $data = shift;
136 2 $self->_output_element;
137  
138 2 my $char = $data->{Data};
139 2 ▶ if ($self->{InCDATA}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'InCDATA'}) { } 0 2 2
140 # we must scan for ]]> in the CDATA and escape it if it
141 # is present by close--opening
142 # we need to have buffer text in front of this...
143 0 $char = join ']]>]]&lt;<![CDATA[', split ']]>', $char;
144 }
145 else {
146 2 $char = $self->escape($char);
147 }
148 2 $char = $self->safeConvert($char);
149 2 $self->{Consumer}->output($char);
150 }
151 #-------------------------------------------------------------------#
152  
153 #-------------------------------------------------------------------#
154 # start_prefix_mapping
155 #-------------------------------------------------------------------#
156 sub start_prefix_mapping {
157 0 ▶ my $self = shift;
Subroutine start_prefix_mapping: not called CC=1 SCAR=6.9
Pod undocumented
158 0 my $data = shift;
159  
160 0 push @{$self->{NSDecl}}, $data;
161 0 $self->{NSHelper}->declarePrefix($data->{Prefix}, $data->{NamespaceURI});
162 }
163 #-------------------------------------------------------------------#
164  
165 #-------------------------------------------------------------------#
166 # end_prefix_mapping
167 #-------------------------------------------------------------------#
168 ▶sub end_prefix_mapping {}
Subroutine end_prefix_mapping: not called CC=1 SCAR=0.0
Pod undocumented
169 #-------------------------------------------------------------------#
170  
171 #-------------------------------------------------------------------#
172 # processing_instruction
173 #-------------------------------------------------------------------#
174 sub processing_instruction {
175 0 ▶ my $self = shift;
Subroutine processing_instruction: not called CC=1 SCAR=6.9
Pod undocumented
176 0 my $data = shift;
177 0 $self->_output_element;
178 0 $self->_output_dtd;
179  
180 0 my $pi = "<?$data->{Target} $data->{Data}?>";
181 0 $pi = $self->safeConvert($pi);
182 0 $self->{Consumer}->output($pi);
183 }
184 #-------------------------------------------------------------------#
185  
186 #-------------------------------------------------------------------#
187 # ignorable_whitespace
188 #-------------------------------------------------------------------#
189 sub ignorable_whitespace {
190 0 ▶ my $self = shift;
Subroutine ignorable_whitespace: not called CC=1 SCAR=6.9
Pod undocumented
191 0 my $data = shift;
192 0 $self->_output_element;
193  
194 0 my $char = $data->{Data};
195 0 $char = $self->escape($char);
196 0 $char = $self->safeConvert($char);
197 0 $self->{Consumer}->output($char);
198 }
199 #-------------------------------------------------------------------#
200  
201 #-------------------------------------------------------------------#
202 # skipped_entity
203 #-------------------------------------------------------------------#
204 sub skipped_entity {
205 0 ▶ my $self = shift;
Subroutine skipped_entity: not called CC=3 SCAR=24.8
Pod undocumented
206 0 my $data = shift;
207 0 $self->_output_element;
208 0 $self->_output_dtd;
209  
210 0 my $ent;
211 0 ▶ if ($data->{Name} =~ m/^%/) {
Branch: 2 branches
BranchTrueFalseTotal
if ($data->{'Name'} =~ /^%/) { } 0 0 0
elsif ($data->{'Name'} eq '[dtd]') { } 0 0 0
212 0 $ent = $data->{Name} . ';';
213  
214 } elsif ($data->{Name} eq '[dtd]') {
215 # ignoring
216  
217 } else {
218 0 $ent = '&' . $data->{Name} . ';';
219 }
220  
221 0 $ent = $self->safeConvert($ent);
222 0 $self->{Consumer}->output($ent);
223  
224 }
225 #-------------------------------------------------------------------#
226  
227 #-------------------------------------------------------------------#
228 # notation_decl
229 #-------------------------------------------------------------------#
230 sub notation_decl {
231 0 ▶ my $self = shift;
Subroutine notation_decl: not called CC=4 SCAR=30.0
Pod undocumented
232 0 my $data = shift;
233 0 $self->_output_dtd;
234  
235 # I think that param entities are normalized before this
236 0 my $not = " <!NOTATION " . $data->{Name};
237 0 ▶ if ($data->{PublicId} and $data->{SystemId}) {
Branch: 2 branches
BranchTrueFalseTotal
if ($data->{'PublicId'} and $data->{'SystemId'}) { } 0 0 0
elsif ($data->{'PublicId'}) { } 0 0 0
Condition0%0/3
$data->{"PublicId"} and $data->{"SystemId"}
!ll&&!rl&&r
000
MC/DC0%0/2
$data->{"PublicId"} and $data->{"SystemId"}
$data->{"PublicId"} $data->{"SystemId"}
Truth table0%0/3
A and B
A= $data->{"PublicId"}B= $data->{"SystemId"}
ABresult
0X0
100
111
238 0 $not .= ' PUBLIC \'' . $self->escape($data->{PublicId}) . '\' \'' . $self->escape($data->{SystemId}) . '\'';
239 }
240 elsif ($data->{PublicId}) {
241 0 $not .= ' PUBLIC \'' . $self->escape($data->{PublicId}) . '\'';
242 }
243 else {
244 0 $not .= ' SYSTEM \'' . $self->escape($data->{SystemId}) . '\'';
245 }
246 0 $not .= " >\n";
247  
248 0 $not = $self->safeConvert($not);
249 0 $self->{Consumer}->output($not);
250 }
251 #-------------------------------------------------------------------#
252  
253 #-------------------------------------------------------------------#
254 # unparsed_entity_decl
255 #-------------------------------------------------------------------#
256 sub unparsed_entity_decl {
257 0 ▶ my $self = shift;
Subroutine unparsed_entity_decl: not called CC=2 SCAR=17.9
Pod undocumented
258 0 my $data = shift;
259 0 $self->_output_dtd;
260  
261 # I think that param entities are normalized before this
262 0 my $ent = " <!ENTITY " . $data->{Name};
263 0 ▶ if ($data->{PublicId}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($data->{'PublicId'}) { } 0 0 0
264 0 $ent .= ' PUBLIC \'' . $self->escape($data->{PublicId}) . '\' \'' . $self->escape($data->{SystemId}) . '\'';
265 }
266 else {
267 0 $ent .= ' SYSTEM \'' . $self->escape($data->{SystemId}) . '\'';
268 }
269 0 $ent .= " NDATA $data->{Notation} >\n";
270  
271 0 $ent = $self->safeConvert($ent);
272 0 $self->{Consumer}->output($ent);
273 }
274 #-------------------------------------------------------------------#
275  
276 #-------------------------------------------------------------------#
277 # element_decl
278 #-------------------------------------------------------------------#
279 sub element_decl {
280 0 ▶ my $self = shift;
Subroutine element_decl: not called CC=1 SCAR=6.9
Pod undocumented
281 0 my $data = shift;
282 0 $self->_output_dtd;
283  
284 # I think that param entities are normalized before this
285 0 my $eld = " <!ELEMENT " . $data->{Name} . ' ' . $data->{Model} . " >\n";
286  
287 0 $eld = $self->safeConvert($eld);
288 0 $self->{Consumer}->output($eld);
289 }
290 #-------------------------------------------------------------------#
291  
292 #-------------------------------------------------------------------#
293 # attribute_decl
294 #-------------------------------------------------------------------#
295 sub attribute_decl {
296 0 ▶ my $self = shift;
Subroutine attribute_decl: not called CC=4 SCAR=30.0
Pod undocumented
297 0 my $data = shift;
298 0 $self->_output_dtd;
299  
300 # to be backward compatible with Perl SAX 2.0
301 $data->{Mode} = $data->{ValueDefault}
302 0 ▶ if not(exists $data->{Mode}) and exists $data->{ValueDefault};
Branch: 1 branch
BranchTrueFalseTotal
if not exists $data->{"Mode"} and exists $data->{"ValueDefault"} 0 0 0
Condition0%0/3
not exists $data->{"Mode"} and exists $data->{"ValueDefault"}
!ll&&!rl&&r
000
MC/DC0%0/2
not exists $data->{"Mode"} and exists $data->{"ValueDefault"}
not exists $data->{"Mode"} exists $data->{"ValueDefault"}
Truth table0%0/3
not(A) and B
A= not exists $data->{"Mode"}B= exists $data->{"ValueDefault"}
ABresult
0X0
100
111
303  
304 # I think that param entities are normalized before this
305 0 my $atd = " <!ATTLIST " . $data->{eName} . ' ' . $data->{aName} . ' ';
306 0 $atd .= $data->{Type} . ' ' . $data->{Mode} . ' ';
307 0 ▶ $atd .= $data->{Value} . ' ' if $data->{Value};
Branch: 1 branch
BranchTrueFalseTotal
if $data->{"Value"} 0 0 0
308 0 $atd .= " >\n";
309  
310 0 $atd = $self->safeConvert($atd);
311 0 $self->{Consumer}->output($atd);
312 }
313 #-------------------------------------------------------------------#
314  
315 #-------------------------------------------------------------------#
316 # internal_entity_decl
317 #-------------------------------------------------------------------#
318 sub internal_entity_decl {
319 0 ▶ my $self = shift;
Subroutine internal_entity_decl: not called CC=1 SCAR=6.9
Pod undocumented
320 0 my $data = shift;
321 0 $self->_output_dtd;
322  
323 # I think that param entities are normalized before this
324 0 my $ent = " <!ENTITY " . $data->{Name} . ' \'' . $self->escape($data->{Value}) . "' >\n";
325 0 $ent = $self->safeConvert($ent);
326 0 $self->{Consumer}->output($ent);
327 }
328 #-------------------------------------------------------------------#
329  
330 #-------------------------------------------------------------------#
331 # external_entity_decl
332 #-------------------------------------------------------------------#
333 sub external_entity_decl {
334 0 ▶ my $self = shift;
Subroutine external_entity_decl: not called CC=2 SCAR=17.9
Pod undocumented
335 0 my $data = shift;
336 0 $self->_output_dtd;
337  
338 # I think that param entities are normalized before this
339 0 my $ent = " <!ENTITY " . $data->{Name};
340 0 ▶ if ($data->{PublicId}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($data->{'PublicId'}) { } 0 0 0
341 0 $ent .= ' PUBLIC \'' . $self->escape($data->{PublicId}) . '\' \'' . $self->escape($data->{SystemId}) . '\'';
342 }
343 else {
344 0 $ent .= ' SYSTEM \'' . $self->escape($data->{SystemId}) . '\'';
345 }
346 0 $ent .= " >\n";
347  
348 0 $ent = $self->safeConvert($ent);
349 0 $self->{Consumer}->output($ent);
350 }
351 #-------------------------------------------------------------------#
352  
353 #-------------------------------------------------------------------#
354 # comment
355 #-------------------------------------------------------------------#
356 sub comment {
357 0 ▶ my $self = shift;
Subroutine comment: not called CC=1 SCAR=6.9
Pod undocumented
358 0 my $data = shift;
359 0 $self->_output_element;
360 0 $self->_output_dtd;
361  
362 0 my $cmt = '<!--' . $self->escapeComment($data->{Data}) . '-->';
363 0 $cmt = $self->safeConvert($cmt);
364 0 $self->{Consumer}->output($cmt);
365 }
366 #-------------------------------------------------------------------#
367  
368 #-------------------------------------------------------------------#
369 # start_dtd
370 #-------------------------------------------------------------------#
371 sub start_dtd {
372 0 ▶ my $self = shift;
Subroutine start_dtd: not called CC=3 SCAR=24.8
Pod undocumented
373 0 my $data = shift;
374  
375 0 my $dtd = '<!DOCTYPE ' . $data->{Name};
376 0 ▶ if ($data->{PublicId}) {
Branch: 2 branches
BranchTrueFalseTotal
if ($data->{'PublicId'}) { } 0 0 0
elsif ($data->{'SystemId'}) { } 0 0 0
377 0 $dtd .= ' PUBLIC \'' . $self->escape($data->{PublicId}) . '\' \'' . $self->escape($data->{SystemId}) . '\'';
378 }
379 elsif ($data->{SystemId}) {
380 0 $dtd .= ' SYSTEM \'' . $self->escape($data->{SystemId}) . '\'';
381 }
382  
383 0 $self->{BufferDTD} = $dtd;
384 }
385 #-------------------------------------------------------------------#
386  
387 #-------------------------------------------------------------------#
388 # end_dtd
389 #-------------------------------------------------------------------#
390 sub end_dtd {
391 0 ▶ my $self = shift;
Subroutine end_dtd: not called CC=2 SCAR=17.9
Pod undocumented
392 0 my $data = shift;
393  
394 0 my $dtd;
395 0 ▶ if ($self->{BufferDTD}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'BufferDTD'}) { } 0 0 0
396 0 $dtd = $self->{BufferDTD} . ' >';
397 }
398 else {
399 0 $dtd = ' ]>';
400 }
401 0 $dtd = $self->safeConvert($dtd);
402 0 $self->{Consumer}->output($dtd);
403 0 $self->{BufferDTD} = '';
404 }
405 #-------------------------------------------------------------------#
406  
407 #-------------------------------------------------------------------#
408 # start_cdata
409 #-------------------------------------------------------------------#
410 sub start_cdata {
411 0 ▶ my $self = shift;
Subroutine start_cdata: not called CC=1 SCAR=6.9
Pod undocumented
412 0 $self->_output_element;
413  
414 0 $self->{InCDATA} = 1;
415 0 my $cds = $self->{Encoder}->convert('<![CDATA[');
416 0 $self->{Consumer}->output($cds);
417 }
418 #-------------------------------------------------------------------#
419  
420 #-------------------------------------------------------------------#
421 # end_cdata
422 #-------------------------------------------------------------------#
423 sub end_cdata {
424 0 ▶ my $self = shift;
Subroutine end_cdata: not called CC=1 SCAR=6.9
Pod undocumented
425  
426 0 $self->{InCDATA} = 0;
427 0 my $cds = $self->{Encoder}->convert(']]>');
428 0 $self->{Consumer}->output($cds);
429 }
430 #-------------------------------------------------------------------#
431  
432 #-------------------------------------------------------------------#
433 # start_entity
434 #-------------------------------------------------------------------#
435 sub start_entity {
436 0 ▶ my $self = shift;
Subroutine start_entity: not called CC=3 SCAR=24.8
Pod undocumented
437 0 my $data = shift;
438 0 $self->_output_element;
439 0 $self->_output_dtd;
440  
441 0 my $ent;
442 0 ▶ if ($data->{Name} eq '[dtd]') {
Branch: 2 branches
BranchTrueFalseTotal
if ($data->{'Name'} eq '[dtd]') { } 0 0 0
elsif ($data->{'Name'} =~ /^%/) { } 0 0 0
443 # we ignore the fact that we're dealing with an external
444 # DTD entity here, and probably shouldn't write the DTD
445 # events unless explicitly told to
446 # this will probably change
447 }
448 elsif ($data->{Name} =~ m/^%/) {
449 0 $ent = $data->{Name} . ';';
450 }
451 else {
452 0 $ent = '&' . $data->{Name} . ';';
453 }
454  
455 0 $ent = $self->safeConvert($ent);
456 0 $self->{Consumer}->output($ent);
457 }
458 #-------------------------------------------------------------------#
459  
460 #-------------------------------------------------------------------#
461 # end_entity
462 #-------------------------------------------------------------------#
463 ▶sub end_entity {
Subroutine end_entity: not called CC=1 SCAR=0.0
Pod undocumented
464 # depending on what is done above, we might need to do sth here
465 }
466 #-------------------------------------------------------------------#
467  
468  
469 ### SAX1 stuff ######################################################
470  
471 #-------------------------------------------------------------------#
472 # xml_decl
473 #-------------------------------------------------------------------#
474 sub xml_decl {
475 0 ▶ my $self = shift;
Subroutine xml_decl: not called CC=4 SCAR=30.0
Pod undocumented
476 0 my $data = shift;
477  
478 # version info is compulsory, contrary to what some seem to think
479 # also, there's order in the pseudo-attr
480 0 my $xd = '';
481 0 ▶ if ($data->{Version}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($data->{"Version"}) 0 0 0
482 0 $xd .= "<?xml version='$data->{Version}'";
483 0 ▶ if ($data->{Encoding}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($data->{"Encoding"}) 0 0 0
484 0 $xd .= " encoding='$data->{Encoding}'";
485 }
486 0 ▶ if ($data->{Standalone}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($data->{"Standalone"}) 0 0 0
487 0 $xd .= " standalone='$data->{Standalone}'";
488 }
489 0 $xd .= '?>';
490 }
491  
492 #$xd = $self->{Encoder}->convert($xd); # this may blow up
493 0 $self->{Consumer}->output($xd);
494 }
495 #-------------------------------------------------------------------#
496  
497  
498 #,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,#
499 #`,`, Helpers `,`,`,`,`,`,`,`,`,`,`,`,`,`,`,`,`,`,`,`,`,`,`,`,`,`,`,#
500 #```````````````````````````````````````````````````````````````````#
501  
502 #-------------------------------------------------------------------#
503 # _output_element
504 #-------------------------------------------------------------------#
505 sub _output_element {
506 6 ▶ my $self = shift;
Subroutine _output_element: called CC=2 SCAR=6.9
507  
508 6 ▶ if ($self->{BufferElement}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"BufferElement"}) 2 4 6
509 2 my $el = $self->{BufferElement} . '>';
510 2 $el = $self->safeConvert($el);
511 2 $self->{Consumer}->output($el);
512 2 $self->{BufferElement} = '';
513 }
514 }
515 #-------------------------------------------------------------------#
516  
517 #-------------------------------------------------------------------#
518 # _output_dtd
519 #-------------------------------------------------------------------#
520 sub _output_dtd {
521 0 ▶ my $self = shift;
Subroutine _output_dtd: not called CC=2 SCAR=17.9
522  
523 0 ▶ if ($self->{BufferDTD}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{"BufferDTD"}) 0 0 0
524 0 my $dtd = $self->{BufferDTD} . " [\n";
525 0 $dtd = $self->safeConvert($dtd);
526 0 $self->{Consumer}->output($dtd);
527 0 $self->{BufferDTD} = '';
528 }
529 }
530 #-------------------------------------------------------------------#
531  
532 5 1;
533 #,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,#
534 #`,`, Documentation `,`,`,`,`,`,`,`,`,`,`,`,`,`,`,`,`,`,`,`,`,`,`,`,#
535 #```````````````````````````````````````````````````````````````````#
536  
537 __END__
↑ Summary Writer.pm »