line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package XML::Atom::Ext::Inline; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
31828
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
31
|
|
4
|
1
|
|
|
1
|
|
6
|
use strict; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
38
|
|
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
5
|
use base qw(XML::Atom::Base); |
|
1
|
|
|
|
|
5
|
|
|
1
|
|
|
|
|
882
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
use XML::Atom::Link; |
9
|
|
|
|
|
|
|
use XML::Atom::Feed; |
10
|
|
|
|
|
|
|
use XML::Atom::Entry; |
11
|
|
|
|
|
|
|
use XML::Atom::Util qw(childlist); |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
use Carp; |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
=head1 NAME |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
XML::Atom::Ext::Inline - In-lining Extensions for Atom |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
=head1 VERSION |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
Version 0.02 |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
=cut |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
our $VERSION = '0.02'; |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
BEGIN { |
28
|
|
|
|
|
|
|
XML::Atom::Link->mk_object_accessor(inline => 'XML::Atom::Ext::Inline'); |
29
|
|
|
|
|
|
|
no warnings; |
30
|
|
|
|
|
|
|
*XML::Atom::Link::set = sub {XML::Atom::Base::set(@_)}; # hack to eliminate backwards compatibility hack in XML::Atom::Link |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
=head1 SYNOPSIS |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
This module implements In-lining extesions for Atom. You can see the RFC draft |
36
|
|
|
|
|
|
|
here: L |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
The following code: |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
use XML::Atom; |
41
|
|
|
|
|
|
|
use XML::Atom::Ext::Inline; |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
my $feed = XML::Atom::Feed->new(Version => '1.0'); |
44
|
|
|
|
|
|
|
my $parent_feed = XML::Atom::Feed->new(Version => '1.0'); |
45
|
|
|
|
|
|
|
$parent_feed->title('foo bar'); |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
my $inline = XML::Atom::Ext::Inline->new(); |
48
|
|
|
|
|
|
|
$inline->atom($parent_feed); |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
my $link = XML::Atom::Link->new(Version => '1.0'); |
51
|
|
|
|
|
|
|
$link->rel('up'); |
52
|
|
|
|
|
|
|
$link->inline($inline); |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
$feed->add_link($link); |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
print $feed->as_xml(); |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
will produce: |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
foo bar |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
=head1 USAGE |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
=head2 atom($feed | $entry) |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
Returns an I or I object representing the |
76
|
|
|
|
|
|
|
inline element contents or C if there is no contents. |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
If given an argument, adds the feed I<$feed> which must be an |
79
|
|
|
|
|
|
|
I object or I<$entry> which must be I |
80
|
|
|
|
|
|
|
object, into inline element. |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
=cut |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
sub atom { |
85
|
|
|
|
|
|
|
my $inline = shift; |
86
|
|
|
|
|
|
|
if (@_) { |
87
|
|
|
|
|
|
|
if ($_[0]->isa('XML::Atom::Feed')) { |
88
|
|
|
|
|
|
|
my ($feed) = @_; |
89
|
|
|
|
|
|
|
my $ns_uri = $feed->{ns}; |
90
|
|
|
|
|
|
|
my @elem = childlist($inline->elem, $ns_uri, 'entry'); |
91
|
|
|
|
|
|
|
$inline->elem->removeChild($_) for @elem; |
92
|
|
|
|
|
|
|
return $inline->set($ns_uri, 'feed', $feed); |
93
|
|
|
|
|
|
|
} |
94
|
|
|
|
|
|
|
elsif ($_[0]->isa('XML::Atom::Feed')) { |
95
|
|
|
|
|
|
|
my ($entry) = @_; |
96
|
|
|
|
|
|
|
my $ns_uri = $entry->{ns}->{uri}; |
97
|
|
|
|
|
|
|
my @elem = childlist($inline->elem, $ns_uri, 'feed'); |
98
|
|
|
|
|
|
|
$inline->elem->removeChild($_) for @elem; |
99
|
|
|
|
|
|
|
return $inline->set($ns_uri, 'entry', $entry); |
100
|
|
|
|
|
|
|
} |
101
|
|
|
|
|
|
|
else { |
102
|
|
|
|
|
|
|
my $r = ref $_[0]; |
103
|
|
|
|
|
|
|
carp "can't embed $r - should be XML::Atom::Feed or XML::Atom::Entry"; |
104
|
|
|
|
|
|
|
return; |
105
|
|
|
|
|
|
|
} |
106
|
|
|
|
|
|
|
} |
107
|
|
|
|
|
|
|
else { |
108
|
|
|
|
|
|
|
# looking for feed or entry or the same stuff again with old NS URI |
109
|
|
|
|
|
|
|
return $inline->get_object('http://www.w3.org/2005/Atom', 'feed', 'XML::Atom::Feed') |
110
|
|
|
|
|
|
|
|| $inline->get_object('http://www.w3.org/2005/Atom', 'entry', 'XML::Atom::Entry') |
111
|
|
|
|
|
|
|
|| $inline->get_object('http://purl.org/atom/ns#', 'feed', 'XML::Atom::Feed') |
112
|
|
|
|
|
|
|
|| $inline->get_object('http://purl.org/atom/ns#', 'entry', 'XML::Atom::Entry'); |
113
|
|
|
|
|
|
|
} |
114
|
|
|
|
|
|
|
} |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
=head2 element_ns |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
Returns the L object representing our xmlns:ae="http://purl.org/atom/ext/">. |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
=cut |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
sub element_ns { |
123
|
|
|
|
|
|
|
return XML::Atom::Namespace->new( |
124
|
|
|
|
|
|
|
'ae' => q{http://purl.org/atom/ext/} |
125
|
|
|
|
|
|
|
); |
126
|
|
|
|
|
|
|
} |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
sub element_name {'inline'} |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
=head1 AUTHOR |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
Dmitri Popov, C<< >> |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
=head1 BUGS |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
Please report more bugs here: L |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
=head1 SUPPORT |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
You can find more information and usefull links on project wiki: L |
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
=head1 COPYRIGHT & LICENSE |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
Copyright 2009-2010 Dmitri Popov, all rights reserved. |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it |
147
|
|
|
|
|
|
|
under the same terms as Perl itself. |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
=cut |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
1; # End of XML::Atom::Ext::Inline |