File Coverage

blib/lib/XML/DOM2/Attribute/Namespace.pm
Criterion Covered Total %
statement 14 31 45.1
branch 0 4 0.0
condition n/a
subroutine 5 10 50.0
pod 6 6 100.0
total 25 51 49.0


line stmt bran cond sub pod time code
1             package XML::DOM2::Attribute::Namespace;
2              
3             =head1 NAME
4              
5             XML::DOM2::Attribute::Namespace
6              
7             =head1 DESCRIPTION
8              
9             Attribute Namespace object class
10              
11             =head1 METHODS
12              
13             =cut
14              
15 3     3   18 use base "XML::DOM2::Attribute";
  3         5  
  3         1647  
16              
17 3     3   22 use strict;
  3         6  
  3         94  
18 3     3   17 use warnings;
  3         5  
  3         78  
19 3     3   16 use Carp;
  3         5  
  3         1185  
20              
21             =head2 $class->new( %arguments )
22              
23             Create a new attribute namespace object.
24              
25             =cut
26             sub new
27             {
28 2     2 1 19 my ($proto, %opts) = @_;
29 2         37 return $proto->SUPER::new(%opts);
30             }
31              
32             =head2 $class->serialise()
33              
34             Format and return xml text serialised.
35              
36             =cut
37             sub serialise
38             {
39 0     0 1   my ($self) = @_;
40 0           my $result = $self->{'value'};
41 0           return $result;
42             }
43              
44             =head2 $class->deserialise( $uri )
45              
46             Deserialise uri
47              
48             =cut
49             sub deserialise
50             {
51 0     0 1   my ($self, $uri) = @_;
52 0 0         if($self->{'value'}) {
53 0           $self->document->removeNamespace($self);
54             }
55 0           $self->{'value'} = $uri;
56 0           $self->document->addNamespace($self);
57 0 0         if($self->name eq 'xmlns') {
58 0           $self->document->namespace($uri);
59             }
60 0           return $self;
61             }
62              
63             =head2 $class->ns_prefix()
64              
65             Return the namespace prefix.
66              
67             =cut
68             sub ns_prefix
69             {
70 0     0 1   my ($self) = @_;
71 0           return $self->localName;
72             }
73              
74             =head2 $class->ns_uri()
75              
76             Return the namespace uri.
77              
78             =cut
79             sub ns_uri
80             {
81 0     0 1   my ($self) = @_;
82 0           return $self->serialise;
83             }
84              
85             =head2 $class->delete()
86              
87             Remove the namespace from the document.
88              
89             =cut
90             sub delete
91             {
92 0     0 1   my ($self) = @_;
93             # Make sure we remove this namespace from
94             # the document when we remove the namespace attribute
95 0           $self->document->removeNamespace($self);
96             }
97              
98             =head1 COPYRIGHT
99              
100             Martin Owens, doctormo@cpan.org
101              
102             =head1 SEE ALSO
103              
104             L,L
105              
106             =cut
107             return 1;