File Coverage

blib/lib/XML/Mini/Element/DocType.pm
Criterion Covered Total %
statement 33 43 76.7
branch 2 6 33.3
condition 1 3 33.3
subroutine 6 7 85.7
pod 2 3 66.6
total 44 62 70.9


line stmt bran cond sub pod time code
1             package XML::Mini::Element::DocType;
2 10     10   51 use strict;
  10         19  
  10         388  
3             $^W = 1;
4              
5 10     10   47 use XML::Mini;
  10         19  
  10         202  
6 10     10   44 use XML::Mini::Element;
  10         17  
  10         265  
7 10     10   65 use vars qw ( $VERSION @ISA );
  10         39  
  10         4005  
8              
9             $VERSION = '1.38';
10             push @ISA, qw ( XML::Mini::Element );
11              
12             sub new
13             {
14 7     7 1 16 my $class = shift;
15 7         13 my $attr = shift;
16 7         18 my $self = {};
17 7   33     66 bless $self, ref $class || $class;
18 7         53 $self->{'_attributes'} = {};
19 7         17 $self->{'_numChildren'} = 0;
20 7         13 $self->{'_numElementChildren'} = 0;
21 7         16 $self->{'_children'} = [];
22 7         14 $self->{'_avoidLoops'} = $XML::Mini::AvoidLoops;
23 7         17 $self->{'_attr'} = $attr;
24 7         43 $self->name('DOCTYPE');
25            
26 7         19 return $self;
27             }
28              
29             sub toString
30             {
31 1     1 1 4 my $self = shift;
32 1         2 my $depth = shift;
33            
34 1         2 my $spaces;
35 1 50       5 if ($depth == $XML::Mini::NoWhiteSpaces)
36             {
37 0         0 $spaces = '';
38             } else {
39 1         9 $spaces = $self->_spaceStr($depth);
40             }
41            
42 1         6 my $retString = "$spaces{'_attr'};
43            
44 1 50       4 if (! $self->{'_numChildren'})
45             {
46            
47 1         3 $retString .= ">\n";
48 1         3 return $retString;
49             }
50            
51 0           $retString .= " [\n";
52            
53            
54 0 0         my $nextDepth = ($depth == $XML::Mini::NoWhiteSpaces) ? $XML::Mini::NoWhiteSpaces
55             : $depth + 1;
56            
57 0           for (my $i=0; $i < $self->{'_numChildren'}; $i++)
58             {
59 0           $retString .= $self->{'_children'}->[$i]->toString($nextDepth);
60             }
61              
62 0           $retString .= "\n]>\n";
63 0           return $retString;
64             }
65              
66              
67             sub toStringNoWhiteSpaces
68             {
69 0     0 0   my $self = shift;
70 0           my $depth = shift;
71 0           return $self->toString($depth);
72             }
73              
74             1;
75              
76             __END__