line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# Copyright (c) 2004-2009 Timothy Appnel |
2
|
|
|
|
|
|
|
# http://appnel.com/ |
3
|
|
|
|
|
|
|
# This code is released under the Artistic License. |
4
|
|
|
|
|
|
|
# |
5
|
|
|
|
|
|
|
# XML::RAI::Item - an interface to the item elements in a RSS feed. |
6
|
|
|
|
|
|
|
# |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
package XML::RAI::Item; |
9
|
|
|
|
|
|
|
|
10
|
1
|
|
|
1
|
|
14255
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
47
|
|
11
|
1
|
|
|
1
|
|
57
|
use XML::RAI::Object; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
use vars qw(@ISA $XMap); |
14
|
|
|
|
|
|
|
@ISA = qw( XML::RAI::Object ); |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
$XMap = { |
17
|
|
|
|
|
|
|
'format' => ['dc:format'], |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
#'link'=>['link','@rdf:about','guid[@isPermaLink="true"]'], # use special handler. |
20
|
|
|
|
|
|
|
abstract => ['dcterms:abstract', 'description', 'dc:description'], |
21
|
|
|
|
|
|
|
content_strict => ['xhtml:body', 'xhtml:div', 'content:encoded'], |
22
|
|
|
|
|
|
|
content => [ |
23
|
|
|
|
|
|
|
'xhtml:body', 'xhtml:div', |
24
|
|
|
|
|
|
|
'content:encoded', 'description', |
25
|
|
|
|
|
|
|
'dc:description', 'rss091:description' |
26
|
|
|
|
|
|
|
], |
27
|
|
|
|
|
|
|
contentstrict => ['xhtml:body', 'xhtml:div', 'content:encoded'] |
28
|
|
|
|
|
|
|
, # deprecated |
29
|
|
|
|
|
|
|
contributor => ['dc:contributor'], |
30
|
|
|
|
|
|
|
coverage => ['dc:coverage'], |
31
|
|
|
|
|
|
|
created_strict => ['dcterms:created'], |
32
|
|
|
|
|
|
|
created => ['dcterms:created', 'dc:date', 'pubDate', 'rss091:pubDate'], |
33
|
|
|
|
|
|
|
creator => ['dc:creator', 'author'], |
34
|
|
|
|
|
|
|
description => ['description', 'dc:description', 'dcterms:abstract'], |
35
|
|
|
|
|
|
|
identifier => |
36
|
|
|
|
|
|
|
['dc:identifier/@rdf:resource', 'dc:identifier', 'guid', 'link'], |
37
|
|
|
|
|
|
|
issued_strict => ['dcterms:issued'], |
38
|
|
|
|
|
|
|
issued => ['dcterms:issued', 'dc:date', 'pubDate', 'rss091:pubDate'], |
39
|
|
|
|
|
|
|
language => [ |
40
|
|
|
|
|
|
|
'@xml:lang', 'dc:language', |
41
|
|
|
|
|
|
|
'/@xml:lang', '/channel/dc:language', |
42
|
|
|
|
|
|
|
'/channel/language', '/channel/rss091:language' |
43
|
|
|
|
|
|
|
], |
44
|
|
|
|
|
|
|
modified_strict => ['dcterms:modified'], |
45
|
|
|
|
|
|
|
modified => ['dcterms:modified', 'dc:date', 'pubDate', 'rss091:pubDate'], |
46
|
|
|
|
|
|
|
ping => ['trackback:ping/@rdf:resource', 'trackback:ping'], |
47
|
|
|
|
|
|
|
pinged => ['trackback:about/@rdf:resource', 'trackback:about'], |
48
|
|
|
|
|
|
|
publisher => [ |
49
|
|
|
|
|
|
|
'dc:publisher', '/channel/dc:publisher', |
50
|
|
|
|
|
|
|
'/channel/managingEditor', '/channel/rss091:managingEditor' |
51
|
|
|
|
|
|
|
], |
52
|
|
|
|
|
|
|
relation => ['dc:relation/@rdf:resource', 'dc:relation'], |
53
|
|
|
|
|
|
|
rights => [ |
54
|
|
|
|
|
|
|
'dc:rights', '/channel/copyright', |
55
|
|
|
|
|
|
|
'/channel/creativeCommons:license', '/channel/rss091:copyright' |
56
|
|
|
|
|
|
|
], |
57
|
|
|
|
|
|
|
source => ['dc:source', 'source/@url', 'source'], |
58
|
|
|
|
|
|
|
subject => ['dc:subject', 'category'], |
59
|
|
|
|
|
|
|
title => ['title', 'dc:title'], |
60
|
|
|
|
|
|
|
type => ['dc:type'], |
61
|
|
|
|
|
|
|
valid => ['dcterms:valid', 'expirationDate'] |
62
|
|
|
|
|
|
|
}; |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
# Class::XPath is missing some functionality we need here so we |
65
|
|
|
|
|
|
|
# help it along. |
66
|
|
|
|
|
|
|
sub link { |
67
|
|
|
|
|
|
|
my $this = shift; |
68
|
|
|
|
|
|
|
my @nodes; |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
# awkward use, but achieves the effect we need. |
71
|
|
|
|
|
|
|
if (@nodes = $this->src->query('link')) { } |
72
|
|
|
|
|
|
|
elsif (@nodes = $this->src->query('@rdf:about')) { } |
73
|
|
|
|
|
|
|
elsif ( |
74
|
|
|
|
|
|
|
@nodes = grep { |
75
|
|
|
|
|
|
|
!$_->attributes |
76
|
|
|
|
|
|
|
|| (!$_->attributes->{isPermaLink} |
77
|
|
|
|
|
|
|
|| $_->attributes->{isPermaLink} eq 'true') |
78
|
|
|
|
|
|
|
} $this->src->query('guid') |
79
|
|
|
|
|
|
|
) |
80
|
|
|
|
|
|
|
{ |
81
|
|
|
|
|
|
|
} |
82
|
|
|
|
|
|
|
elsif ( |
83
|
|
|
|
|
|
|
@nodes = grep { |
84
|
|
|
|
|
|
|
$_->attributes->{type} =~ m!^(text/html|application/xhtml+xml)$! |
85
|
|
|
|
|
|
|
} $this->src->query('l:link[@rel="permalink"]') |
86
|
|
|
|
|
|
|
) |
87
|
|
|
|
|
|
|
{ |
88
|
|
|
|
|
|
|
} |
89
|
|
|
|
|
|
|
elsif (@nodes = $this->src->query('comment')) { |
90
|
|
|
|
|
|
|
} |
91
|
|
|
|
|
|
|
my @n = map { ref($_) ? $_->text_content : $_ } @nodes; |
92
|
|
|
|
|
|
|
wantarray ? @n : $n[0]; |
93
|
|
|
|
|
|
|
} |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
1; |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
__END__ |