File Coverage

blib/lib/XML/Mini/Element/CData.pm
Criterion Covered Total %
statement 12 45 26.6
branch 0 8 0.0
condition 0 3 0.0
subroutine 4 7 57.1
pod 2 3 66.6
total 18 66 27.2


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