| 1 | package HTML::TreeBuilder::LibXML::Node; | ||||||||||||||||||||||||||||
| 2 | 23 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 3 | 23 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 23 | ▶ | use Carp(); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||
| 6 | 131 | ▶ | sub new { | ||||||||||||||||||||||||||
|
Subroutine
new: called CC=5 SCAR=16.2
Pod
undocumented
| |||||||||||||||||||||||||||||
| 7 | 131 | my $class = shift; | |||||||||||||||||||||||||||
| 8 | 131 | ▶ | Carp::croak 'missing arguments' unless @_>=1; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 9 | 131 | ▶ | if (@_==1 && ref($_[0])) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
@_ == 1 and ref $_[0]
MC/DC50%1/2
@_ == 1 and ref $_[0]
@_ == 1
ref $_[0]
Truth table66%2/3
A and B
A= @_ == 1B= ref $_[0]
| |||||||||||||||||||||||||||||
| 10 | 130 | bless {node => $_[0]}, $class; | |||||||||||||||||||||||||||
| 11 | } else { | ||||||||||||||||||||||||||||
| 12 | 1 | my ($tag, @attrs) = @_; | |||||||||||||||||||||||||||
| 13 | 1 | my $doc = XML::LibXML->createDocument; | |||||||||||||||||||||||||||
| 14 | 1 | my $node = $doc->createElement($tag); | |||||||||||||||||||||||||||
| 15 | 1 | ▶ | while (my ($k, $v) = splice @attrs, 0, 2) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 16 | 1 | $node->setAttribute($k, $v); | |||||||||||||||||||||||||||
| 17 | } | ||||||||||||||||||||||||||||
| 18 | 1 | bless {node => $node}, $class; | |||||||||||||||||||||||||||
| 19 | } | ||||||||||||||||||||||||||||
| 20 | } | ||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||
| 22 | 31 | ▶ | sub attr { | ||||||||||||||||||||||||||
|
Subroutine
attr: called CC=5 SCAR=16.1
Pod
undocumented
| |||||||||||||||||||||||||||||
| 23 | 31 | my ($self, $key, $value) = @_; | |||||||||||||||||||||||||||
| 24 | 31 | ▶ | if (@_ == 3) { | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 25 | 2 | ▶ | if (defined $value) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 26 | 1 | $self->{node}->setAttribute (lc $key, $value); | |||||||||||||||||||||||||||
| 27 | } else { | ||||||||||||||||||||||||||||
| 28 | 1 | $self->{node}->removeAttribute(lc $key); | |||||||||||||||||||||||||||
| 29 | } | ||||||||||||||||||||||||||||
| 30 | ▶ | } elsif (@_ == 2 and lc $key eq 'text') { | |||||||||||||||||||||||||||
|
Condition66%2/3
@_ == 2 and lc $key eq "text"
MC/DC50%1/2
@_ == 2 and lc $key eq "text"
@_ == 2
lc $key eq "text"
Truth table66%2/3
A and B
A= @_ == 2B= lc $key eq "text"
| |||||||||||||||||||||||||||||
| 31 | 13 | return $self->{node}->textContent; | |||||||||||||||||||||||||||
| 32 | } | ||||||||||||||||||||||||||||
| 33 | 18 | $self->{node}->getAttribute(lc $key); | |||||||||||||||||||||||||||
| 34 | } | ||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||
| 36 | 1 | ▶ | sub isTextNode { | ||||||||||||||||||||||||||
|
Subroutine
isTextNode: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 37 | 1 | my $self = shift; | |||||||||||||||||||||||||||
| 38 | 1 | $self->{node}->isa('XML::LibXML::Text'); | |||||||||||||||||||||||||||
| 39 | } | ||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||
| 41 | # The analog of HTML::TreeBuilder::XPath::getValue for comment nodes | ||||||||||||||||||||||||||||
| 42 | 23 | *getValue = \&as_text; | |||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||
| 44 | 1 | ▶ | sub string_value { | ||||||||||||||||||||||||||
|
Subroutine
string_value: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 45 | 1 | $_[0]->{node}->textContent; | |||||||||||||||||||||||||||
| 46 | } | ||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||
| 48 | 11 | ▶ | sub as_text { | ||||||||||||||||||||||||||
|
Subroutine
as_text: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 49 | 11 | $_[0]->{node}->textContent; | |||||||||||||||||||||||||||
| 50 | } | ||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||
| 52 | 2 | ▶ | sub as_trimmed_text { | ||||||||||||||||||||||||||
|
Subroutine
as_trimmed_text: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 53 | 2 | my $text = shift->as_text(@_); | |||||||||||||||||||||||||||
| 54 | 2 | $text =~ s/[\n\r\f\t ]+$//s; | |||||||||||||||||||||||||||
| 55 | 2 | $text =~ s/^[\n\r\f\t ]+//s; | |||||||||||||||||||||||||||
| 56 | 2 | $text =~ s/[\n\r\f\t ]+/ /g; | |||||||||||||||||||||||||||
| 57 | 2 | return $text; | |||||||||||||||||||||||||||
| 58 | } | ||||||||||||||||||||||||||||
| 59 | 1 | ▶ | sub as_text_trimmed { shift->as_trimmed_text(@_) } # alias | ||||||||||||||||||||||||||
|
Subroutine
as_text_trimmed: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||
| 61 | 1 | ▶ | sub objectify_text { } | ||||||||||||||||||||||||||
|
Subroutine
objectify_text: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 62 | 0 | ▶ | sub deobjectify_text { } | ||||||||||||||||||||||||||
|
Subroutine
deobjectify_text: not called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||
| 64 | 3 | ▶ | sub as_XML { | ||||||||||||||||||||||||||
|
Subroutine
as_XML: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 65 | 3 | $_[0]->{node}->toString; | |||||||||||||||||||||||||||
| 66 | } | ||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||
| 68 | 42 | ▶ | sub as_HTML { | ||||||||||||||||||||||||||
|
Subroutine
as_HTML: called CC=4 SCAR=13.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 69 | 42 | ▶ | return $_[0]->{node}->toStringHTML if $_[0]->{node}->can('toStringHTML'); # best method, but only document nodes can toStringHTML() | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||
| 71 | # second best is to call toStringC14N(1), which generates valid HTML (eg. no auto closed <div/>), | ||||||||||||||||||||||||||||
| 72 | # but dies on some cases with "Failed to convert doc to string in doc->toStringC14N" error. | ||||||||||||||||||||||||||||
| 73 | # so we fallback to toString() | ||||||||||||||||||||||||||||
| 74 | { | ||||||||||||||||||||||||||||
| 75 | 37 | local $@; # protect existing $@ | |||||||||||||||||||||||||||
| 76 | 37 | my $output = eval { $_[0]->{node}->toStringC14N(1) }; | |||||||||||||||||||||||||||
| 77 | 37 | ▶ | return $_[0]->{node}->toString if ($@ or $output eq ''); | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$@ or $output eq ""
MC/DC50%1/2
$@ or $output eq ""
$@
$output eq ""
Truth table66%2/3
A or B
A= $@B= $output eq ""
| |||||||||||||||||||||||||||||
| 78 | 34 | return $output; | |||||||||||||||||||||||||||
| 79 | } | ||||||||||||||||||||||||||||
| 80 | } | ||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||
| 82 | 3 | ▶ | sub tag { | ||||||||||||||||||||||||||
|
Subroutine
tag: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 83 | $_[0]->{node}->localname | ||||||||||||||||||||||||||||
| 84 | 3 | } | |||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||
| 86 | 4 | ▶ | sub id { | ||||||||||||||||||||||||||
|
Subroutine
id: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 87 | 4 | ▶ | if (@_==2) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 88 | # setter | ||||||||||||||||||||||||||||
| 89 | 2 | ▶ | if (defined $_[1]) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 90 | 1 | $_[0]->{node}->setAttribute('id', $_[1]); | |||||||||||||||||||||||||||
| 91 | } else { | ||||||||||||||||||||||||||||
| 92 | 1 | $_[0]->{node}->removeAttribute('id'); | |||||||||||||||||||||||||||
| 93 | } | ||||||||||||||||||||||||||||
| 94 | } else { | ||||||||||||||||||||||||||||
| 95 | 2 | $_[0]->{node}->getAttribute('id'); | |||||||||||||||||||||||||||
| 96 | } | ||||||||||||||||||||||||||||
| 97 | } | ||||||||||||||||||||||||||||
| 98 | |||||||||||||||||||||||||||||
| 99 | # hack for Web::Scraper | ||||||||||||||||||||||||||||
| 100 | 3 | ▶ | sub isa { | ||||||||||||||||||||||||||
|
Subroutine
isa: called CC=2 SCAR=7.2
Pod
undocumented
| |||||||||||||||||||||||||||||
| 101 | 3 | my ($self, $klass) = @_; | |||||||||||||||||||||||||||
| 102 | 3 | ▶ | $klass eq 'HTML::Element' ? 1 : UNIVERSAL::isa($self, $klass); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 103 | } | ||||||||||||||||||||||||||||
| 104 | |||||||||||||||||||||||||||||
| 105 | 2 | ▶ | sub exists { | ||||||||||||||||||||||||||
|
Subroutine
exists: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 106 | 2 | my( $self , $xpath ) = @_; | |||||||||||||||||||||||||||
| 107 | |||||||||||||||||||||||||||||
| 108 | 2 | ▶ | $self->_eof_or_die unless $self->{node}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 109 | 2 | my @nodes = $self->{node}->findnodes( $xpath ); | |||||||||||||||||||||||||||
| 110 | 2 | ▶ | return scalar( @nodes ) ? 1 : 0; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 111 | } | ||||||||||||||||||||||||||||
| 112 | |||||||||||||||||||||||||||||
| 113 | 2 | ▶ | sub find { | ||||||||||||||||||||||||||
|
Subroutine
find: called CC=3 SCAR=11.2
Pod
undocumented
| |||||||||||||||||||||||||||||
| 114 | 2 | my( $self , $elem ) = @_; | |||||||||||||||||||||||||||
| 115 | |||||||||||||||||||||||||||||
| 116 | 2 | ▶ | $self->_eof_or_die unless $self->{node}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 117 | |||||||||||||||||||||||||||||
| 118 | 2 | my @nodes = $self->{node}->getElementsByTagName( $elem ); | |||||||||||||||||||||||||||
| 119 | 2 | @nodes = map { HTML::TreeBuilder::LibXML::Node->new( $_ ) } @nodes; | |||||||||||||||||||||||||||
| 120 | |||||||||||||||||||||||||||||
| 121 | 2 | ▶ | wantarray ? @nodes : \@nodes; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 122 | } | ||||||||||||||||||||||||||||
| 123 | |||||||||||||||||||||||||||||
| 124 | 24 | ▶ | sub findnodes { | ||||||||||||||||||||||||||
|
Subroutine
findnodes: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 125 | 24 | my ($self, $xpath) = @_; | |||||||||||||||||||||||||||
| 126 | |||||||||||||||||||||||||||||
| 127 | 24 | ▶ | $self->_eof_or_die unless $self->{node}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 128 | 24 | my @nodes = $self->{node}->findnodes( $xpath ); | |||||||||||||||||||||||||||
| 129 | 24 | @nodes = map { HTML::TreeBuilder::LibXML::Node->new($_) } @nodes; | |||||||||||||||||||||||||||
| 130 | 24 | ▶ | wantarray ? @nodes : \@nodes; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 131 | } | ||||||||||||||||||||||||||||
| 132 | |||||||||||||||||||||||||||||
| 133 | 23 | *findnodes_as_string = \&findvalue; | |||||||||||||||||||||||||||
| 134 | 23 | *findnodes_as_strings = \&findvalues; | |||||||||||||||||||||||||||
| 135 | |||||||||||||||||||||||||||||
| 136 | 1 | ▶ | sub findnodes_filter { | ||||||||||||||||||||||||||
|
Subroutine
findnodes_filter: called CC=4 SCAR=15.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 137 | 1 | my( $self , $xpath , $callback ) = @_; | |||||||||||||||||||||||||||
| 138 | |||||||||||||||||||||||||||||
| 139 | 1 | ▶ | Carp::croak "Second argument must be coderef" | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$callback and ref $callback eq "CODE"
MC/DC0%0/2
$callback and ref $callback eq "CODE"
$callback
ref $callback eq "CODE"
Truth table33%1/3
A and B
A= $callbackB= ref $callback eq "CODE"
| |||||||||||||||||||||||||||||
| 140 | unless $callback and ref $callback eq 'CODE'; | ||||||||||||||||||||||||||||
| 141 | |||||||||||||||||||||||||||||
| 142 | 1 | my @nodes = $self->findnodes( $xpath ); | |||||||||||||||||||||||||||
| 143 | 1 | @nodes = grep { $callback->($_) } @nodes; | |||||||||||||||||||||||||||
| 144 | |||||||||||||||||||||||||||||
| 145 | 1 | ▶ | wantarray ? @nodes : \@nodes; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 146 | } | ||||||||||||||||||||||||||||
| 147 | |||||||||||||||||||||||||||||
| 148 | 21 | ▶ | sub findvalue { | ||||||||||||||||||||||||||
|
Subroutine
findvalue: called CC=2 SCAR=7.1
Pod
undocumented
| |||||||||||||||||||||||||||||
| 149 | 21 | my ($self, $xpath) = @_; | |||||||||||||||||||||||||||
| 150 | |||||||||||||||||||||||||||||
| 151 | 21 | ▶ | $self->_eof_or_die unless $self->{node}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 152 | 21 | $self->{node}->findvalue( $xpath ); | |||||||||||||||||||||||||||
| 153 | } | ||||||||||||||||||||||||||||
| 154 | |||||||||||||||||||||||||||||
| 155 | 2 | ▶ | sub findvalues { | ||||||||||||||||||||||||||
|
Subroutine
findvalues: called CC=3 SCAR=11.2
Pod
undocumented
| |||||||||||||||||||||||||||||
| 156 | 2 | my( $self , $xpath ) = @_; | |||||||||||||||||||||||||||
| 157 | |||||||||||||||||||||||||||||
| 158 | 2 | ▶ | $self->_eof_or_die unless $self->{node}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 159 | 2 | my $nodes = $self->{node}->find( $xpath ); | |||||||||||||||||||||||||||
| 160 | 2 | my @nodes = map { $_->textContent } $nodes->get_nodelist; | |||||||||||||||||||||||||||
| 161 | 2 | ▶ | wantarray ? @nodes : \@nodes; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 162 | } | ||||||||||||||||||||||||||||
| 163 | |||||||||||||||||||||||||||||
| 164 | 3 | ▶ | sub clone { | ||||||||||||||||||||||||||
|
Subroutine
clone: called CC=3 SCAR=11.4
Pod
undocumented
| |||||||||||||||||||||||||||||
| 165 | 3 | my ($self, ) = @_; | |||||||||||||||||||||||||||
| 166 | |||||||||||||||||||||||||||||
| 167 | 3 | my $orignode = $self->{node}; | |||||||||||||||||||||||||||
| 168 | 3 | my $origdoc = $orignode->ownerDocument; | |||||||||||||||||||||||||||
| 169 | |||||||||||||||||||||||||||||
| 170 | 3 | my $node = $orignode->cloneNode(1); | |||||||||||||||||||||||||||
| 171 | |||||||||||||||||||||||||||||
| 172 | # arguments can be undefined | ||||||||||||||||||||||||||||
| 173 | 3 | my $doc = do { | |||||||||||||||||||||||||||
| 174 | 23 | ▶ | no warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 175 | 3 | XML::LibXML::Document->new($origdoc->version, $origdoc->encoding); | |||||||||||||||||||||||||||
| 176 | }; | ||||||||||||||||||||||||||||
| 177 | |||||||||||||||||||||||||||||
| 178 | 3 | ▶ | if ($node->isa('XML::LibXML::Dtd')) { | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 179 | 0 | $doc->createInternalSubset( $node->getName, $node->publicId, $node->systemId ); | |||||||||||||||||||||||||||
| 180 | 0 | $node = $doc->internalSubset; | |||||||||||||||||||||||||||
| 181 | } elsif ($node->isa('XML::LibXML::Element')) { | ||||||||||||||||||||||||||||
| 182 | 3 | $doc->setDocumentElement($node); | |||||||||||||||||||||||||||
| 183 | } else { | ||||||||||||||||||||||||||||
| 184 | 0 | $doc->adoptNode($node); | |||||||||||||||||||||||||||
| 185 | } | ||||||||||||||||||||||||||||
| 186 | |||||||||||||||||||||||||||||
| 187 | 3 | my $cloned = __PACKAGE__->new($node); | |||||||||||||||||||||||||||
| 188 | 3 | return $cloned; | |||||||||||||||||||||||||||
| 189 | } | ||||||||||||||||||||||||||||
| 190 | |||||||||||||||||||||||||||||
| 191 | 1 | ▶ | sub clone_list { | ||||||||||||||||||||||||||
|
Subroutine
clone_list: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 192 | 1 | my $class = shift; | |||||||||||||||||||||||||||
| 193 | 1 | my @clones = map { $_->clone } @_; | |||||||||||||||||||||||||||
| 194 | 1 | @clones; | |||||||||||||||||||||||||||
| 195 | } | ||||||||||||||||||||||||||||
| 196 | |||||||||||||||||||||||||||||
| 197 | 4 | ▶ | sub detach { | ||||||||||||||||||||||||||
|
Subroutine
detach: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 198 | 4 | my $self = shift; | |||||||||||||||||||||||||||
| 199 | 4 | my $parent = $self->parent; | |||||||||||||||||||||||||||
| 200 | #$self->{node}->unbindNode(); | ||||||||||||||||||||||||||||
| 201 | 4 | my $doc = XML::LibXML->createDocument; | |||||||||||||||||||||||||||
| 202 | 4 | $doc->adoptNode($self->{node}); | |||||||||||||||||||||||||||
| 203 | 4 | $doc->setDocumentElement($self->{node}); | |||||||||||||||||||||||||||
| 204 | 4 | $parent; | |||||||||||||||||||||||||||
| 205 | } | ||||||||||||||||||||||||||||
| 206 | |||||||||||||||||||||||||||||
| 207 | 6 | ▶ | sub delete { | ||||||||||||||||||||||||||
|
Subroutine
delete: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 208 | 6 | my $self = shift; | |||||||||||||||||||||||||||
| 209 | 6 | $self->{node}->unbindNode(); | |||||||||||||||||||||||||||
| 210 | } | ||||||||||||||||||||||||||||
| 211 | |||||||||||||||||||||||||||||
| 212 | 1 | ▶ | sub delete_content { | ||||||||||||||||||||||||||
|
Subroutine
delete_content: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 213 | 1 | my ($self) = @_; | |||||||||||||||||||||||||||
| 214 | 1 | $self->{node}->removeChildNodes; | |||||||||||||||||||||||||||
| 215 | } | ||||||||||||||||||||||||||||
| 216 | |||||||||||||||||||||||||||||
| 217 | 0 | ▶ | sub getFirstChild { | ||||||||||||||||||||||||||
|
Subroutine
getFirstChild: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 218 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 219 | 0 | __PACKAGE__->new($self->{node}->getFirstChild); | |||||||||||||||||||||||||||
| 220 | } | ||||||||||||||||||||||||||||
| 221 | |||||||||||||||||||||||||||||
| 222 | 3 | ▶ | sub childNodes { | ||||||||||||||||||||||||||
|
Subroutine
childNodes: called CC=3 SCAR=11.2
Pod
undocumented
| |||||||||||||||||||||||||||||
| 223 | 3 | my $self = shift; | |||||||||||||||||||||||||||
| 224 | |||||||||||||||||||||||||||||
| 225 | 3 | ▶ | $self->_eof_or_die unless $self->{node}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 226 | 3 | my @nodes = $self->{node}->childNodes; | |||||||||||||||||||||||||||
| 227 | 3 | @nodes = map { __PACKAGE__->new($_) } @nodes; | |||||||||||||||||||||||||||
| 228 | 3 | ▶ | wantarray ? @nodes : \@nodes; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 229 | } | ||||||||||||||||||||||||||||
| 230 | |||||||||||||||||||||||||||||
| 231 | 2 | ▶ | sub content_list { | ||||||||||||||||||||||||||
|
Subroutine
content_list: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 232 | 2 | my ($self) = @_; | |||||||||||||||||||||||||||
| 233 | 2 | my @nodes = $self->childNodes; | |||||||||||||||||||||||||||
| 234 | 2 | @nodes; | |||||||||||||||||||||||||||
| 235 | } | ||||||||||||||||||||||||||||
| 236 | |||||||||||||||||||||||||||||
| 237 | 3 | ▶ | sub replace_with { | ||||||||||||||||||||||||||
|
Subroutine
replace_with: called CC=8 SCAR=21.2
Pod
undocumented
| |||||||||||||||||||||||||||||
| 238 | 3 | my $self = shift; | |||||||||||||||||||||||||||
| 239 | |||||||||||||||||||||||||||||
| 240 | # TODO handle @_ == 0 | ||||||||||||||||||||||||||||
| 241 | |||||||||||||||||||||||||||||
| 242 | 3 | my $node = $self->{node}; | |||||||||||||||||||||||||||
| 243 | 3 | my $doc = $node->ownerDocument; | |||||||||||||||||||||||||||
| 244 | 3 | my $parent = $node->parentNode; | |||||||||||||||||||||||||||
| 245 | 3 | ▶ | die "can't replace_with(), node has no parent!" unless $parent; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 246 | |||||||||||||||||||||||||||||
| 247 | 3 | ▶ | my @nodes = map { ref $_ ? $_->{node} : $doc->createTextNode($_) } @_; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 248 | |||||||||||||||||||||||||||||
| 249 | 3 | ▶ | if ($parent->isa('XML::LibXML::Document')) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 250 | # can't call insertBefore() in a document node, | ||||||||||||||||||||||||||||
| 251 | # so this is the best hack so far :[ | ||||||||||||||||||||||||||||
| 252 | # works only if $node is the last child | ||||||||||||||||||||||||||||
| 253 | 1 | ▶ | die "[not supported] calling replace_with() in a node that is child of a document node, and its not the last child." | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 254 | unless $node->isSameNode($parent->lastChild); | ||||||||||||||||||||||||||||
| 255 | |||||||||||||||||||||||||||||
| 256 | 1 | foreach (@nodes) { | |||||||||||||||||||||||||||
| 257 | |||||||||||||||||||||||||||||
| 258 | 3 | ▶ | if ($_->isa('XML::LibXML::Dtd')) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 259 | 0 | $parent->createInternalSubset($_->getName, $_->publicId, $_->systemId); | |||||||||||||||||||||||||||
| 260 | 0 | next; | |||||||||||||||||||||||||||
| 261 | } | ||||||||||||||||||||||||||||
| 262 | 3 | $parent->adoptNode($_); | |||||||||||||||||||||||||||
| 263 | 3 | $node->addSibling($_); | |||||||||||||||||||||||||||
| 264 | } | ||||||||||||||||||||||||||||
| 265 | |||||||||||||||||||||||||||||
| 266 | } | ||||||||||||||||||||||||||||
| 267 | else { | ||||||||||||||||||||||||||||
| 268 | $parent->insertBefore($_, $node) | ||||||||||||||||||||||||||||
| 269 | 2 | for @nodes; | |||||||||||||||||||||||||||
| 270 | } | ||||||||||||||||||||||||||||
| 271 | |||||||||||||||||||||||||||||
| 272 | 3 | $self->detach; | |||||||||||||||||||||||||||
| 273 | 3 | $self; | |||||||||||||||||||||||||||
| 274 | } | ||||||||||||||||||||||||||||
| 275 | |||||||||||||||||||||||||||||
| 276 | 2 | ▶ | sub push_content { | ||||||||||||||||||||||||||
|
Subroutine
push_content: called CC=7 SCAR=19.5
Pod
undocumented
| |||||||||||||||||||||||||||||
| 277 | 2 | my $self = shift; | |||||||||||||||||||||||||||
| 278 | |||||||||||||||||||||||||||||
| 279 | 2 | my $node = $self->{node}; | |||||||||||||||||||||||||||
| 280 | 2 | ▶ | my $doc = $node->isa('XML::LibXML::Document') ? $node : $node->ownerDocument; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 281 | 2 | ▶ | my @nodes = map { ref $_ ? $_->{node} : $doc->createTextNode($_) } @_; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 282 | |||||||||||||||||||||||||||||
| 283 | # thats because appendChild() is not supported on a Document node (as of XML::LibXML 2.0017) | ||||||||||||||||||||||||||||
| 284 | 2 | ▶ | if ($node->isa('XML::LibXML::Document')) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 285 | |||||||||||||||||||||||||||||
| 286 | 1 | foreach (@nodes) { | |||||||||||||||||||||||||||
| 287 | #$node->adoptNode($_); | ||||||||||||||||||||||||||||
| 288 | 1 | ▶ | $node->hasChildNodes ? $node->lastChild->addSibling($_) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 289 | : $node->setDocumentElement($_); | ||||||||||||||||||||||||||||
| 290 | } | ||||||||||||||||||||||||||||
| 291 | } | ||||||||||||||||||||||||||||
| 292 | else { | ||||||||||||||||||||||||||||
| 293 | 1 | $node->appendChild($_) for @nodes; | |||||||||||||||||||||||||||
| 294 | } | ||||||||||||||||||||||||||||
| 295 | |||||||||||||||||||||||||||||
| 296 | 2 | $self; | |||||||||||||||||||||||||||
| 297 | } | ||||||||||||||||||||||||||||
| 298 | |||||||||||||||||||||||||||||
| 299 | 2 | ▶ | sub unshift_content { | ||||||||||||||||||||||||||
|
Subroutine
unshift_content: called CC=9 SCAR=22.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 300 | 2 | my $self = shift; | |||||||||||||||||||||||||||
| 301 | |||||||||||||||||||||||||||||
| 302 | return $self->push_content(@_) | ||||||||||||||||||||||||||||
| 303 | 2 | ▶ | unless $self->{node}->hasChildNodes; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 304 | |||||||||||||||||||||||||||||
| 305 | 2 | my $node = $self->{node}; | |||||||||||||||||||||||||||
| 306 | 2 | ▶ | my $doc = $node->isa('XML::LibXML::Document') ? $node : $node->ownerDocument; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 307 | 2 | ▶ | my @nodes = map { ref $_ ? $_->{node} : $doc->createTextNode($_) } @_; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 308 | |||||||||||||||||||||||||||||
| 309 | # thats because insertBefore() is not supported on a Document node (as of XML::LibXML 2.0017) | ||||||||||||||||||||||||||||
| 310 | 2 | ▶ | if ($node->isa('XML::LibXML::Document')) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 311 | |||||||||||||||||||||||||||||
| 312 | 1 | foreach (@nodes) { | |||||||||||||||||||||||||||
| 313 | 1 | ▶ | $node->hasChildNodes ? $node->lastChild->addSibling($_) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 314 | : $node->setDocumentElement($_); | ||||||||||||||||||||||||||||
| 315 | } | ||||||||||||||||||||||||||||
| 316 | |||||||||||||||||||||||||||||
| 317 | # rotate | ||||||||||||||||||||||||||||
| 318 | 1 | ▶ | while (not $node->firstChild->isSameNode($nodes[0])) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 319 | 1 | my $first_node = $node->firstChild; | |||||||||||||||||||||||||||
| 320 | 1 | $first_node->unbindNode; | |||||||||||||||||||||||||||
| 321 | 1 | $node->lastChild->addSibling($first_node); | |||||||||||||||||||||||||||
| 322 | |||||||||||||||||||||||||||||
| 323 | } | ||||||||||||||||||||||||||||
| 324 | } | ||||||||||||||||||||||||||||
| 325 | else { | ||||||||||||||||||||||||||||
| 326 | 1 | my $first_child = $node->firstChild; | |||||||||||||||||||||||||||
| 327 | 1 | $node->insertBefore($_, $first_child) for @nodes; | |||||||||||||||||||||||||||
| 328 | } | ||||||||||||||||||||||||||||
| 329 | |||||||||||||||||||||||||||||
| 330 | 2 | $self; | |||||||||||||||||||||||||||
| 331 | } | ||||||||||||||||||||||||||||
| 332 | |||||||||||||||||||||||||||||
| 333 | 1 | ▶ | sub left { | ||||||||||||||||||||||||||
|
Subroutine
left: called CC=3 SCAR=11.4
Pod
undocumented
| |||||||||||||||||||||||||||||
| 334 | 1 | my $self = shift; | |||||||||||||||||||||||||||
| 335 | |||||||||||||||||||||||||||||
| 336 | 1 | ▶ | $self->_eof_or_die unless $self->{node}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 337 | 1 | my $prev = $self->{node}->previousNonBlankSibling; | |||||||||||||||||||||||||||
| 338 | 1 | ▶ | return $prev ? __PACKAGE__->new( $prev ) : undef; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 339 | } | ||||||||||||||||||||||||||||
| 340 | |||||||||||||||||||||||||||||
| 341 | 1 | ▶ | sub right { | ||||||||||||||||||||||||||
|
Subroutine
right: called CC=3 SCAR=11.4
Pod
undocumented
| |||||||||||||||||||||||||||||
| 342 | 1 | my $self = shift; | |||||||||||||||||||||||||||
| 343 | |||||||||||||||||||||||||||||
| 344 | 1 | ▶ | $self->_eof_or_die unless $self->{node}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 345 | 1 | my $next = $self->{node}->nextNonBlankSibling; | |||||||||||||||||||||||||||
| 346 | 1 | ▶ | return $next ? __PACKAGE__->new( $next ) : undef; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 347 | } | ||||||||||||||||||||||||||||
| 348 | |||||||||||||||||||||||||||||
| 349 | 7 | ▶ | sub look_down { | ||||||||||||||||||||||||||
|
Subroutine
look_down: called CC=12 SCAR=25.2
Pod
undocumented
| |||||||||||||||||||||||||||||
| 350 | 7 | my $self = shift; | |||||||||||||||||||||||||||
| 351 | 7 | my @args = @_; | |||||||||||||||||||||||||||
| 352 | |||||||||||||||||||||||||||||
| 353 | 7 | ▶ | $self->_eof_or_die unless $self->{node}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 354 | |||||||||||||||||||||||||||||
| 355 | 7 | my @filter; | |||||||||||||||||||||||||||
| 356 | 7 | my $xpath = "//*"; # default | |||||||||||||||||||||||||||
| 357 | 7 | ▶ | while (@args) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 358 | 10 | ▶ | if (ref $args[0] eq 'CODE') { | ||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||
| 359 | 3 | my $code = shift @args; | |||||||||||||||||||||||||||
| 360 | 3 | push @filter, $code; | |||||||||||||||||||||||||||
| 361 | ▶ | } elsif (@args >= 2 && $args[0] eq '_tag') { | |||||||||||||||||||||||||||
|
Condition66%2/3
@args >= 2 and $args[0] eq "_tag"
MC/DC50%1/2
@args >= 2 and $args[0] eq "_tag"
@args >= 2
$args[0] eq "_tag"
Truth table66%2/3
A and B
A= @args >= 2B= $args[0] eq "_tag"
| |||||||||||||||||||||||||||||
| 362 | 6 | my($tag, $want_tag) = splice(@args, 0, 2); | |||||||||||||||||||||||||||
| 363 | 6 | $xpath = "//$want_tag"; | |||||||||||||||||||||||||||
| 364 | } elsif (@args >= 2) { | ||||||||||||||||||||||||||||
| 365 | 1 | my($attr, $stuff) = splice(@args, 0, 2); | |||||||||||||||||||||||||||
| 366 | 1 | ▶ | if (ref $stuff eq 'Regexp') { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 367 | 23 | ▶ | push @filter, sub { no warnings 'uninitialized'; $_[0]->attr($attr) =~ $stuff }; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 368 | } else { | ||||||||||||||||||||||||||||
| 369 | 0 | ▶ | push @filter, sub { no warnings 'uninitialized'; $_[0]->attr($attr) eq $stuff }; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.6
Subroutine
__ANON__: not called CC=1 SCAR=0.6
| |||||||||||||||||||||||||||||
| 370 | } | ||||||||||||||||||||||||||||
| 371 | } else { | ||||||||||||||||||||||||||||
| 372 | 0 | Carp::carp("Don't know what to do with @args"); | |||||||||||||||||||||||||||
| 373 | 0 | shift @args; | |||||||||||||||||||||||||||
| 374 | } | ||||||||||||||||||||||||||||
| 375 | } | ||||||||||||||||||||||||||||
| 376 | |||||||||||||||||||||||||||||
| 377 | 7 | $xpath =~ s/~text\b/text()/g; | |||||||||||||||||||||||||||
| 378 | |||||||||||||||||||||||||||||
| 379 | 7 | my @nodes = $self->findnodes($xpath); | |||||||||||||||||||||||||||
| 380 | my @wants = grep { | ||||||||||||||||||||||||||||
| 381 | 7 | my $node = $_; | |||||||||||||||||||||||||||
| 382 | 30 | my $ok = 1; | |||||||||||||||||||||||||||
| 383 | 30 | for my $filter (@filter) { | |||||||||||||||||||||||||||
| 384 | 24 | ▶ | $filter->($_) or $ok = 0; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 385 | } | ||||||||||||||||||||||||||||
| 386 | 30 | ▶ | $ok ? $node : (); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 387 | } @nodes; | ||||||||||||||||||||||||||||
| 388 | |||||||||||||||||||||||||||||
| 389 | 7 | ▶ | wantarray ? @wants : $wants[0]; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 390 | } | ||||||||||||||||||||||||||||
| 391 | |||||||||||||||||||||||||||||
| 392 | 1 | ▶ | sub all_attr { | ||||||||||||||||||||||||||
|
Subroutine
all_attr: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 393 | 1 | my $self = shift; | |||||||||||||||||||||||||||
| 394 | 1 | return map { $_->name => $_->value } $self->{node}->attributes; | |||||||||||||||||||||||||||
| 395 | } | ||||||||||||||||||||||||||||
| 396 | |||||||||||||||||||||||||||||
| 397 | 1 | ▶ | sub all_attr_names { | ||||||||||||||||||||||||||
|
Subroutine
all_attr_names: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 398 | 1 | my $self = shift; | |||||||||||||||||||||||||||
| 399 | 1 | return map $_->name, $self->{node}->attributes; | |||||||||||||||||||||||||||
| 400 | } | ||||||||||||||||||||||||||||
| 401 | |||||||||||||||||||||||||||||
| 402 | 1 | ▶ | sub all_external_attr { shift->all_attr(@_) } | ||||||||||||||||||||||||||
|
Subroutine
all_external_attr: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 403 | 1 | ▶ | sub all_external_attr_names { shift->all_attr_names(@_) } | ||||||||||||||||||||||||||
|
Subroutine
all_external_attr_names: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 404 | |||||||||||||||||||||||||||||
| 405 | 1 | ▶ | sub _eof_or_die { | ||||||||||||||||||||||||||
|
Subroutine
_eof_or_die: called CC=2 SCAR=7.6
| |||||||||||||||||||||||||||||
| 406 | 1 | my $self = shift; | |||||||||||||||||||||||||||
| 407 | 1 | ▶ | if (defined($self->{_content})) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 408 | 1 | $self->eof; | |||||||||||||||||||||||||||
| 409 | } else { | ||||||||||||||||||||||||||||
| 410 | 0 | Carp::croak "\$self is not loaded: $self" | |||||||||||||||||||||||||||
| 411 | } | ||||||||||||||||||||||||||||
| 412 | } | ||||||||||||||||||||||||||||
| 413 | |||||||||||||||||||||||||||||
| 414 | |||||||||||||||||||||||||||||
| 415 | 2 | ▶ | sub matches { | ||||||||||||||||||||||||||
|
Subroutine
matches: called CC=3 SCAR=11.1
Pod
undocumented
| |||||||||||||||||||||||||||||
| 416 | 2 | my ($self, $xpath) = @_; | |||||||||||||||||||||||||||
| 417 | |||||||||||||||||||||||||||||
| 418 | 2 | foreach ($self->{node}->ownerDocument->findnodes($xpath)) { | |||||||||||||||||||||||||||
| 419 | 1 | ▶ | return 1 if $_->isEqual($self->{node}); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 420 | } | ||||||||||||||||||||||||||||
| 421 | |||||||||||||||||||||||||||||
| 422 | 1 | return; | |||||||||||||||||||||||||||
| 423 | } | ||||||||||||||||||||||||||||
| 424 | |||||||||||||||||||||||||||||
| 425 | 23 | ▶ | sub parent { | ||||||||||||||||||||||||||
|
Subroutine
parent: called CC=8 SCAR=20.8
Pod
undocumented
| |||||||||||||||||||||||||||||
| 426 | 23 | my $self = shift; | |||||||||||||||||||||||||||
| 427 | |||||||||||||||||||||||||||||
| 428 | 23 | ▶ | if (@_) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 429 | |||||||||||||||||||||||||||||
| 430 | # unset | ||||||||||||||||||||||||||||
| 431 | 4 | ▶ | unless (defined $_[0]) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 432 | 1 | $self->{node}->unbindNode; | |||||||||||||||||||||||||||
| 433 | 1 | return; | |||||||||||||||||||||||||||
| 434 | } | ||||||||||||||||||||||||||||
| 435 | |||||||||||||||||||||||||||||
| 436 | # set | ||||||||||||||||||||||||||||
| 437 | Carp::croak "an element can't be made its own parent" | ||||||||||||||||||||||||||||
| 438 | 3 | ▶ | if ref $_[0]->{node}->isSameNode($self->{node}); # sanity | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 439 | |||||||||||||||||||||||||||||
| 440 | 3 | my $parent = $_[0]->{node}; | |||||||||||||||||||||||||||
| 441 | |||||||||||||||||||||||||||||
| 442 | 3 | ▶ | if ($_[0]->{node}->isa('XML::LibXML::Document')) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 443 | |||||||||||||||||||||||||||||
| 444 | 2 | ▶ | if ($parent->hasChildNodes) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 445 | 1 | $parent->lastChild->addSibling($self->{node}); | |||||||||||||||||||||||||||
| 446 | } | ||||||||||||||||||||||||||||
| 447 | else { | ||||||||||||||||||||||||||||
| 448 | 1 | $parent->adoptNode($self->{node}); | |||||||||||||||||||||||||||
| 449 | 1 | $parent->setDocumentElement($self->{node}); | |||||||||||||||||||||||||||
| 450 | } | ||||||||||||||||||||||||||||
| 451 | |||||||||||||||||||||||||||||
| 452 | } | ||||||||||||||||||||||||||||
| 453 | else { | ||||||||||||||||||||||||||||
| 454 | 1 | $parent->appendChild($self->{node}); | |||||||||||||||||||||||||||
| 455 | } | ||||||||||||||||||||||||||||
| 456 | |||||||||||||||||||||||||||||
| 457 | } | ||||||||||||||||||||||||||||
| 458 | else { | ||||||||||||||||||||||||||||
| 459 | # get | ||||||||||||||||||||||||||||
| 460 | 19 | my $parent = $self->{node}->parentNode; | |||||||||||||||||||||||||||
| 461 | 19 | ▶ | return defined $parent && !$parent->isa('XML::LibXML::DocumentFragment')? ref($self)->new($parent) : undef; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
defined $parent and not $parent->isa("XML::LibXML::DocumentFragment")
MC/DC50%1/2
defined $parent and not $parent->isa("XML::LibXML::DocumentFragment")
defined $parent
not $parent->isa("XML::LibXML::DocumentFragment")
Truth table66%2/3
A and not(B)
A= defined $parentB= not $parent->isa("XML::LibXML::DocumentFragment")
| |||||||||||||||||||||||||||||
| 462 | } | ||||||||||||||||||||||||||||
| 463 | |||||||||||||||||||||||||||||
| 464 | } | ||||||||||||||||||||||||||||
| 465 | |||||||||||||||||||||||||||||
| 466 | 1 | ▶ | sub postinsert { | ||||||||||||||||||||||||||
|
Subroutine
postinsert: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 467 | 1 | my $self = shift; | |||||||||||||||||||||||||||
| 468 | 1 | my @nodes = map { $_->{node} } @_; | |||||||||||||||||||||||||||
| 469 | 1 | my $parent = $self->{node}->parentNode; | |||||||||||||||||||||||||||
| 470 | |||||||||||||||||||||||||||||
| 471 | $parent->insertAfter($_, $self->{node}) | ||||||||||||||||||||||||||||
| 472 | 1 | foreach reverse @nodes; | |||||||||||||||||||||||||||
| 473 | |||||||||||||||||||||||||||||
| 474 | 1 | $self; | |||||||||||||||||||||||||||
| 475 | } | ||||||||||||||||||||||||||||
| 476 | |||||||||||||||||||||||||||||
| 477 | 1 | ▶ | sub preinsert { | ||||||||||||||||||||||||||
|
Subroutine
preinsert: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 478 | 1 | my $self = shift; | |||||||||||||||||||||||||||
| 479 | 1 | my @nodes = map { $_->{node} } @_; | |||||||||||||||||||||||||||
| 480 | 1 | my $parent = $self->{node}->parentNode; | |||||||||||||||||||||||||||
| 481 | |||||||||||||||||||||||||||||
| 482 | $parent->insertBefore($_, $self->{node}) | ||||||||||||||||||||||||||||
| 483 | 1 | foreach @nodes; | |||||||||||||||||||||||||||
| 484 | |||||||||||||||||||||||||||||
| 485 | 1 | $self; | |||||||||||||||||||||||||||
| 486 | } | ||||||||||||||||||||||||||||
| 487 | |||||||||||||||||||||||||||||
| 488 | |||||||||||||||||||||||||||||
| 489 | |||||||||||||||||||||||||||||
| 490 | 23 | 1; | |||||||||||||||||||||||||||
| 491 | |||||||||||||||||||||||||||||
| 492 | __END__ | ||||||||||||||||||||||||||||