File Coverage

blib/lib/XML/DOM2/DOM/NameSpace.pm
Criterion Covered Total %
statement 16 23 69.5
branch 3 10 30.0
condition n/a
subroutine 6 7 85.7
pod 5 5 100.0
total 30 45 66.6


line stmt bran cond sub pod time code
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 3     3   18 use strict;
  3         7  
  3         102  
16 3     3   16 use Carp;
  3         4  
  3         1073  
17              
18             =head2 $element->name()
19              
20             Returns the attributes full name with namespace prefix.
21              
22             =cut
23             sub name
24             {
25 59     59 1 79 my ($self) = @_;
26 59         149 my $prefix = $self->prefix;
27 59 50       158 return ($prefix ? $prefix.':' : '').$self->localName;
28             }
29              
30             =head2 $element->localName()
31              
32             Returns the attribute name without name space prefix.
33              
34             =cut
35             sub localName
36             {
37 82     82 1 2625 my ($self) = @_;
38 82 50       190 confess "Does not have a self object for some reason\n" if not $self;
39 82         394 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             {
49 0     0 1 0 my ($self) = @_;
50 0 0       0 return if not $self->namespace;
51 0         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             {
61 59     59 1 79 my ($self) = @_;
62 59 50       128 return if not $self->namespace;
63 0 0       0 if(not ref($self->namespace)) {
64 0         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         0 return;
66             }
67 0         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             {
77 59     59 1 68 my ($self) = @_;
78 59         193 return $self->{'namespace'};
79             }
80              
81             =head1 COPYRIGHT
82              
83             Martin Owens, doctormo@cpan.org
84              
85             =head1 SEE ALSO
86              
87             L
88              
89             =cut
90             1;