line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# $Id$ |
2
|
|
|
|
|
|
|
# |
3
|
|
|
|
|
|
|
# Copyright (c) 2005 Daisuke Maki |
4
|
|
|
|
|
|
|
# All rights reserved. |
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
package XML::RSS::LibXML::MagicElement; |
7
|
1
|
|
|
1
|
|
4
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
52
|
|
8
|
|
|
|
|
|
|
use overload |
9
|
0
|
|
|
0
|
|
0
|
bool => sub { 1 }, |
10
|
1
|
|
|
|
|
11
|
'""' => \&toString, |
11
|
|
|
|
|
|
|
fallback => 1 |
12
|
1
|
|
|
1
|
|
4
|
; |
|
1
|
|
|
|
|
2
|
|
13
|
1
|
|
|
1
|
|
78
|
use vars qw($VERSION); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
801
|
|
14
|
|
|
|
|
|
|
$VERSION = '0.3105'; |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
# Make UNIVERSAL::isa happy |
17
|
0
|
|
0
|
0
|
0
|
|
sub isa { __PACKAGE__ eq ($_[1] || '') } |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
sub new |
20
|
|
|
|
|
|
|
{ |
21
|
0
|
|
|
0
|
1
|
|
my $class = shift; |
22
|
0
|
|
|
|
|
|
my %args = @_; |
23
|
|
|
|
|
|
|
|
24
|
0
|
|
|
|
|
|
my %attrs; |
25
|
|
|
|
|
|
|
my @attrs; |
26
|
0
|
|
|
|
|
|
my $attrs = $args{attributes}; |
27
|
0
|
0
|
|
|
|
|
if (ref($attrs) eq 'ARRAY') { |
|
|
0
|
|
|
|
|
|
28
|
0
|
0
|
0
|
|
|
|
%attrs = map { ( |
|
0
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
29
|
|
|
|
|
|
|
$_->prefix && $_->prefix ne 'xmlns' ? |
30
|
|
|
|
|
|
|
sprintf('%s:%s', $_->prefix, $_->localname || '') : |
31
|
|
|
|
|
|
|
$_->localname || '' |
32
|
|
|
|
|
|
|
, $_->getData |
33
|
|
|
|
|
|
|
) } @$attrs; |
34
|
0
|
|
|
|
|
|
@attrs = map { $_->getName } @$attrs; |
|
0
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
} elsif (ref($attrs) eq 'HASH') { |
36
|
0
|
|
|
|
|
|
%attrs = %$attrs; |
37
|
0
|
|
|
|
|
|
@attrs = keys %$attrs; |
38
|
|
|
|
|
|
|
} else { |
39
|
0
|
|
|
|
|
|
die "'attributes' must be an arrayref of XML::LibXML::Attr objects, or a hashref of scalars"; |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
0
|
|
|
|
|
|
return bless { |
43
|
|
|
|
|
|
|
%attrs, |
44
|
|
|
|
|
|
|
_attributes => \@attrs, |
45
|
|
|
|
|
|
|
_content => $args{content}, |
46
|
|
|
|
|
|
|
}, $class; |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
sub attributes |
50
|
|
|
|
|
|
|
{ |
51
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
52
|
0
|
0
|
|
|
|
|
return wantarray ? @{$self->{_attributes}} : $self->{_attributes}; |
|
0
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
sub toString |
56
|
|
|
|
|
|
|
{ |
57
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
58
|
0
|
0
|
|
|
|
|
return (defined $self->{_content} && length $self->{_content}) ? |
59
|
|
|
|
|
|
|
$self->{_content} : |
60
|
0
|
0
|
0
|
|
|
|
join('', map { $self->{$_} || '' } $self->attributes); |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
1; |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
__END__ |