DOM2/DOM/NameSpace.pm

filter: Statementstmt 70.8% 17 / 24 Branchbran 30.0% 3 / 10 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 85.7% 6 / 7 Podpod 100% 5 / 5 totaltotal 67.3% 31 / 46 CC 6 SCAR 12.4
CC
6
Cov
59%
prefix
6.1
namespaceURI
6.0
name
2.0
CRAP 3.4
« DOM2/Attribute/Namespace.pm ↑ Summary DOM2/Element/CDATA.pm »
1 package XML::DOM2::DOM::NameSpace;
2  
3 =head1 NAME
4  
5 XML::DOM2::DOM::NameSpace
6  
7 =head1 DESCRIPTION
8  
9 NameSpace base class for all attributes and elements
10  
11 =head1 METHODS
12  
13 =cut
14  
15 4 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
16 4 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
17  
18 =head2 $element->name()
19  
20 Returns the attributes full name with namespace prefix.
21  
22 =cut
23 sub name
24 59 ▶{
Subroutine name: called CC=2 SCAR=7.1
Pod documented
25 59 my ($self) = @_;
26 59 my $prefix = $self->prefix;
27 59 ▶ return ($prefix ? $prefix.':' : '').$self->localName;
Branch: 1 branch
BranchTrueFalseTotal
$prefix ? : 0 59 59
28 }
29  
30 =head2 $element->localName()
31  
32 Returns the attribute name without name space prefix.
33  
34 =cut
35 sub localName
36 82 ▶{
Subroutine localName: called CC=2 SCAR=7.1
Pod documented
37 82 my ($self) = @_;
38 82 ▶ confess "Does not have a self object for some reason\n" if not $self;
Branch: 1 branch
BranchTrueFalseTotal
unless $self 0 82 82
39 82 return $self->{'name'};
40 }
41  
42 =head2 $element->namespaceURI()
43  
44 Returns the URI of the attributes namespace.
45  
46 =cut
47 sub namespaceURI
48 0 ▶{
Subroutine namespaceURI: not called CC=2 SCAR=17.9
Pod documented
49 0 my ($self) = @_;
50 0 ▶ return if not $self->namespace;
Branch: 1 branch
BranchTrueFalseTotal
unless $self->namespace 0 0 0
51 0 return $self->namespace->ns_uri;
52 }
53  
54 =head2 $element->prefix()
55  
56 Returns the attributes namespace prefix, returns undef if the namespace is the same as the owning element.
57  
58 =cut
59 sub prefix
60 59 ▶{
Subroutine prefix: called CC=3 SCAR=18.1
Pod documented
61 59 my ($self) = @_;
62 59 ▶ return if not $self->namespace;
Branch: 1 branch
BranchTrueFalseTotal
unless $self->namespace 59 0 59
63 0 ▶ if(not ref($self->namespace)) {
Branch: 1 branch
BranchTrueFalseTotal
unless (ref $self->namespace) 0 0 0
64 0 warn "This name space is not right, I'd find out what gave it to you if I were you ".$self->namespace.':'.$self->localName.':'.$self." \n";
65 0 return;
66 }
67 0 return $self->namespace->ns_prefix;
68 }
69  
70 =head2 $element->namespace()
71  
72 Return the namespace string this element or attribute belongs to.
73  
74 =cut
75 sub namespace
76 59 ▶{
Subroutine namespace: called CC=1 SCAR=0.0
Pod documented
77 59 my ($self) = @_;
78 59 return $self->{'namespace'};
79 }
80  
81 =head1 COPYRIGHT
82  
83 Martin Owens, doctormo@cpan.org
84  
85 =head1 SEE ALSO
86  
87 L<XML::DOM2>
88  
89 =cut
90 4 1;
« DOM2/Attribute/Namespace.pm ↑ Summary DOM2/Element/CDATA.pm »