| 1 | package XML::DOM::Lite::Document; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | 8 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 8 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||
| 6 | 8 | ▶ | use Carp qw (carp croak cluck); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||
| 8 | 8 | ▶ | use XML::DOM::Lite::Constants qw(:all); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 9 | 8 | ▶ | use XML::DOM::Lite::XPath; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||
| 11 | 8 | ▶ | use base qw(XML::DOM::Lite::Node); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||
| 13 | sub new { | ||||||||||||||||||||||||||||
| 14 | 12 | ▶ | my ($class) = @_; | ||||||||||||||||||||||||||
|
Subroutine
new: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 15 | 12 | return bless $class->SUPER::new({ | |||||||||||||||||||||||||||
| 16 | nodeName => '#document', | ||||||||||||||||||||||||||||
| 17 | nodeType => DOCUMENT_NODE, | ||||||||||||||||||||||||||||
| 18 | childNodes => [ ], | ||||||||||||||||||||||||||||
| 19 | elements => { }, | ||||||||||||||||||||||||||||
| 20 | }), $class; | ||||||||||||||||||||||||||||
| 21 | } | ||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||
| 23 | 3 | ▶ | sub parentNode { undef } | ||||||||||||||||||||||||||
|
Subroutine
parentNode: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||
| 25 | sub appendChild { | ||||||||||||||||||||||||||||
| 26 | 17 | ▶ | my ($self, $node) = @_; | ||||||||||||||||||||||||||
|
Subroutine
appendChild: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 27 | 17 | ▶ | if (not $self->{documentElement} and ($node->nodeType == ELEMENT_NODE)) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
not $self->{"documentElement"} and $node->nodeType == 1
MC/DC100%2/2
not $self->{"documentElement"} and $node->nodeType == 1
not $self->{"documentElement"}
$node->nodeType == 1
Truth table100%3/3
not(A) and B
A= not $self->{"documentElement"}B= $node->nodeType == 1
| |||||||||||||||||||||||||||||
| 28 | 12 | $self->{documentElement} = $node; | |||||||||||||||||||||||||||
| 29 | } | ||||||||||||||||||||||||||||
| 30 | 17 | return $self->SUPER::appendChild($node); | |||||||||||||||||||||||||||
| 31 | } | ||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||
| 33 | sub setElementById { | ||||||||||||||||||||||||||||
| 34 | 7 | ▶ | my ($self, $id, $node) = @_; | ||||||||||||||||||||||||||
|
Subroutine
setElementById: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 35 | 7 | $self->{elements}->{$id} = $node; | |||||||||||||||||||||||||||
| 36 | } | ||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||
| 38 | sub getElementById { | ||||||||||||||||||||||||||||
| 39 | 2 | ▶ | my ($self, $id) = @_; | ||||||||||||||||||||||||||
|
Subroutine
getElementById: called CC=2 SCAR=7.2
Pod
undocumented
| |||||||||||||||||||||||||||||
| 40 | 2 | ▶ | return $self->{elements}->{$id} if exists $self->{elements}->{$id}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 41 | } | ||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||
| 43 | sub createElement { | ||||||||||||||||||||||||||||
| 44 | 4 | ▶ | my ($self, $tagName) = @_; | ||||||||||||||||||||||||||
|
Subroutine
createElement: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 45 | 4 | my $node = XML::DOM::Lite::Node->new({ | |||||||||||||||||||||||||||
| 46 | nodeName => $tagName, | ||||||||||||||||||||||||||||
| 47 | tagName => $tagName, | ||||||||||||||||||||||||||||
| 48 | nodeType => ELEMENT_NODE, | ||||||||||||||||||||||||||||
| 49 | }); | ||||||||||||||||||||||||||||
| 50 | 4 | $node->ownerDocument($self); | |||||||||||||||||||||||||||
| 51 | 4 | return $node; | |||||||||||||||||||||||||||
| 52 | } | ||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||
| 54 | sub createAttribute { | ||||||||||||||||||||||||||||
| 55 | 0 | ▶ | my ($self, $nodeName) = @_; | ||||||||||||||||||||||||||
|
Subroutine
createAttribute: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 56 | 0 | my $attr = XML::DOM::Lite::Node->new({ | |||||||||||||||||||||||||||
| 57 | nodeName => $nodeName, | ||||||||||||||||||||||||||||
| 58 | nodeType => ATTRIBUTE_NODE, | ||||||||||||||||||||||||||||
| 59 | }); | ||||||||||||||||||||||||||||
| 60 | 0 | $attr->ownerDocument($self); | |||||||||||||||||||||||||||
| 61 | 0 | return $attr; | |||||||||||||||||||||||||||
| 62 | } | ||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||
| 64 | sub createTextNode { | ||||||||||||||||||||||||||||
| 65 | 1 | ▶ | my ($self, $str) = @_; | ||||||||||||||||||||||||||
|
Subroutine
createTextNode: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 66 | 1 | my $node = XML::DOM::Lite::Node->new({ | |||||||||||||||||||||||||||
| 67 | nodeName => '#text', | ||||||||||||||||||||||||||||
| 68 | nodeType => TEXT_NODE, | ||||||||||||||||||||||||||||
| 69 | nodeValue => $str, | ||||||||||||||||||||||||||||
| 70 | }); | ||||||||||||||||||||||||||||
| 71 | 1 | $node->ownerDocument($self); | |||||||||||||||||||||||||||
| 72 | 1 | return $node; | |||||||||||||||||||||||||||
| 73 | } | ||||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||
| 75 | sub createDocumentFragment { | ||||||||||||||||||||||||||||
| 76 | 2 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
createDocumentFragment: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 77 | 2 | my $frag = XML::DOM::Lite::Node->new({ | |||||||||||||||||||||||||||
| 78 | nodeName => '#document-fragment', | ||||||||||||||||||||||||||||
| 79 | nodeType => DOCUMENT_FRAGMENT_NODE, | ||||||||||||||||||||||||||||
| 80 | ownerDocument => $self, | ||||||||||||||||||||||||||||
| 81 | }); | ||||||||||||||||||||||||||||
| 82 | 2 | $frag->ownerDocument($self); | |||||||||||||||||||||||||||
| 83 | 2 | return $frag; | |||||||||||||||||||||||||||
| 84 | } | ||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||
| 86 | sub documentElement { | ||||||||||||||||||||||||||||
| 87 | 20 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
documentElement: called CC=2 SCAR=7.6
Pod
undocumented
| |||||||||||||||||||||||||||||
| 88 | 20 | ▶ | if (@_) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 89 | 0 | $self->{documentElement} = shift; | |||||||||||||||||||||||||||
| 90 | } | ||||||||||||||||||||||||||||
| 91 | 20 | $self->{documentElement}; | |||||||||||||||||||||||||||
| 92 | } | ||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||
| 94 | sub selectNodes { | ||||||||||||||||||||||||||||
| 95 | 1 | ▶ | my ($self, $path) = @_; | ||||||||||||||||||||||||||
|
Subroutine
selectNodes: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 96 | 1 | return XML::DOM::Lite::XPath->evaluate($path, $self); | |||||||||||||||||||||||||||
| 97 | } | ||||||||||||||||||||||||||||
| 98 | |||||||||||||||||||||||||||||
| 99 | sub selectSingleNode { | ||||||||||||||||||||||||||||
| 100 | 1 | ▶ | my ($self, $path) = @_; | ||||||||||||||||||||||||||
|
Subroutine
selectSingleNode: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 101 | 1 | return $self->selectNodes($path)->[0]; | |||||||||||||||||||||||||||
| 102 | } | ||||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||
| 104 | sub elements { | ||||||||||||||||||||||||||||
| 105 | 0 | ▶ | return $_[0]->{elements}; | ||||||||||||||||||||||||||
|
Subroutine
elements: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 106 | } | ||||||||||||||||||||||||||||
| 107 | |||||||||||||||||||||||||||||
| 108 | sub xml { | ||||||||||||||||||||||||||||
| 109 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
xml: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 110 | 0 | my $serializer = XML::DOM::Lite::Serializer->new; | |||||||||||||||||||||||||||
| 111 | 0 | return $serializer->serializeToString($self->documentElement); | |||||||||||||||||||||||||||
| 112 | } | ||||||||||||||||||||||||||||
| 113 | |||||||||||||||||||||||||||||
| 114 | 8 | 1; | |||||||||||||||||||||||||||
| 115 | __END__ | ||||||||||||||||||||||||||||