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::Channel - an interface to the channel elements of a RSS feed. |
6
|
|
|
|
|
|
|
# |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
package XML::RAI::Channel; |
9
|
|
|
|
|
|
|
|
10
|
1
|
|
|
1
|
|
3445
|
use strict; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
47
|
|
11
|
1
|
|
|
1
|
|
579
|
use XML::RAI::Object; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
use vars qw(@ISA $XMap); |
14
|
|
|
|
|
|
|
@ISA = qw( XML::RAI::Object ); |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
use XML::RAI; |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
$XMap = { |
19
|
|
|
|
|
|
|
'format' => ['dc:format'], |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
# 'link'=>['link','@rdf:about'], #special handler |
22
|
|
|
|
|
|
|
contributor => ['dc:contributor'], |
23
|
|
|
|
|
|
|
coverage => ['dc:coverage'], |
24
|
|
|
|
|
|
|
creator => ['dc:creator'], |
25
|
|
|
|
|
|
|
description => [ |
26
|
|
|
|
|
|
|
'description', 'dc:description', |
27
|
|
|
|
|
|
|
'dcterms:abstract', 'dcterms:alternative' |
28
|
|
|
|
|
|
|
], |
29
|
|
|
|
|
|
|
generator => [ |
30
|
|
|
|
|
|
|
'admin:generatorAgent/@rdf:resource', 'admin:generatorAgent', |
31
|
|
|
|
|
|
|
'generator' |
32
|
|
|
|
|
|
|
], |
33
|
|
|
|
|
|
|
identifier => ['dc:identifier/@rdf:resource', 'dc:identifier', 'link'], |
34
|
|
|
|
|
|
|
issued_strict => ['dcterms:issued'], |
35
|
|
|
|
|
|
|
issued => |
36
|
|
|
|
|
|
|
['dcterms:issued', 'dc:date', 'lastBuildDate', 'rss091:lastBuildDate'], |
37
|
|
|
|
|
|
|
language => ['@xml:lang', 'dc:language', 'language', 'rss091:language'], |
38
|
|
|
|
|
|
|
maintainer => [ |
39
|
|
|
|
|
|
|
'admin:errorReportsTo/@rdf:resource', 'admin:errorReportsTo', |
40
|
|
|
|
|
|
|
'webMaster' |
41
|
|
|
|
|
|
|
], |
42
|
|
|
|
|
|
|
modified_strict => ['dcterms:modified'], |
43
|
|
|
|
|
|
|
modified => [ |
44
|
|
|
|
|
|
|
'dcterms:modified', 'dc:date', |
45
|
|
|
|
|
|
|
'lastBuildDate', 'rss091:lastBuildDate', |
46
|
|
|
|
|
|
|
], |
47
|
|
|
|
|
|
|
publisher => ['dc:publisher', 'managingEditor', 'rss091:managingEditor'], |
48
|
|
|
|
|
|
|
relation => ['dc:relation/@rdf:resource', 'dc:relation'], |
49
|
|
|
|
|
|
|
rights => [ |
50
|
|
|
|
|
|
|
'dc:rights', 'copyright', |
51
|
|
|
|
|
|
|
'creativeCommons:license', 'rss091:copyright' |
52
|
|
|
|
|
|
|
], |
53
|
|
|
|
|
|
|
source => ['dc:source', 'source/@url', 'source', 'title'], |
54
|
|
|
|
|
|
|
subject => ['dc:subject', 'category'], |
55
|
|
|
|
|
|
|
title => ['title', 'dc:title'], |
56
|
|
|
|
|
|
|
type => ['dc:type'], |
57
|
|
|
|
|
|
|
valid => ['dcterms:valid', 'expirationDate'], |
58
|
|
|
|
|
|
|
}; |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
# Class::XPath is missing some functionality we need here so we |
61
|
|
|
|
|
|
|
# help it along. |
62
|
|
|
|
|
|
|
sub link { |
63
|
|
|
|
|
|
|
my $this = shift; |
64
|
|
|
|
|
|
|
my @nodes; |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
# awkward use, but achieves the effect we need. |
67
|
|
|
|
|
|
|
if (@nodes = $this->src->query('link')) { } |
68
|
|
|
|
|
|
|
elsif ( |
69
|
|
|
|
|
|
|
@nodes = grep { |
70
|
|
|
|
|
|
|
$_->attributes->{type} =~ m!^(text/html|application/xhtml+xml)$! |
71
|
|
|
|
|
|
|
} $this->src->query('l:link[@rel="permalink"]') |
72
|
|
|
|
|
|
|
) |
73
|
|
|
|
|
|
|
{ |
74
|
|
|
|
|
|
|
} |
75
|
|
|
|
|
|
|
elsif (@nodes = $this->src->query('dc:relation/@rdf:resource')) { |
76
|
|
|
|
|
|
|
} |
77
|
|
|
|
|
|
|
elsif (@nodes = $this->src->query('dc:relation')) { |
78
|
|
|
|
|
|
|
} |
79
|
|
|
|
|
|
|
return unless (defined $nodes[0]); |
80
|
|
|
|
|
|
|
my @n = map { ref($_) ? $_->text_content : $_ } @nodes; |
81
|
|
|
|
|
|
|
wantarray ? @n : $n[0]; |
82
|
|
|
|
|
|
|
} |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
1; |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
__END__ |