| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
## XML::Generator::RSS10::egms |
|
2
|
|
|
|
|
|
|
## An extension to Dave Rolsky's XML::Generator::RSS10 to handle the UK Government eGMS category metadata |
|
3
|
|
|
|
|
|
|
## Written by Andrew Green, Article Seven, http://www.article7.co.uk/ |
|
4
|
|
|
|
|
|
|
## Sponsored by Woking Borough Council, http://www.woking.gov.uk/ |
|
5
|
|
|
|
|
|
|
## Last updated: Tuesday, 02 May 2006 |
|
6
|
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
package XML::Generator::RSS10::egms; |
|
8
|
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
$VERSION = '0.02'; |
|
10
|
|
|
|
|
|
|
|
|
11
|
1
|
|
|
1
|
|
25927
|
use strict; |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
40
|
|
|
12
|
1
|
|
|
1
|
|
5
|
use Carp; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
100
|
|
|
13
|
|
|
|
|
|
|
|
|
14
|
1
|
|
|
1
|
|
1074
|
use XML::Generator::RSS10::gcl; |
|
|
1
|
|
|
|
|
1532
|
|
|
|
1
|
|
|
|
|
25
|
|
|
15
|
1
|
|
|
1
|
|
834
|
use XML::Generator::RSS10::lgcl; |
|
|
1
|
|
|
|
|
372
|
|
|
|
1
|
|
|
|
|
23
|
|
|
16
|
1
|
|
|
1
|
|
445
|
use XML::Generator::RSS10::ipsv; |
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
use base 'XML::Generator::RSS10::Module'; |
|
19
|
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
1; |
|
21
|
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
#### |
|
23
|
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
sub NamespaceURI { |
|
25
|
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
'http://www.esd.org.uk/standards/egms/3.0/egms-schema#' |
|
27
|
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
} |
|
29
|
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
#### |
|
31
|
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
sub contents { |
|
33
|
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
my $self = shift; |
|
35
|
|
|
|
|
|
|
my $rss = shift; |
|
36
|
|
|
|
|
|
|
my $p = shift; |
|
37
|
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
foreach my $elt ( sort keys %{$p} ) { |
|
39
|
|
|
|
|
|
|
if ($elt eq 'SubjectCategory') { |
|
40
|
|
|
|
|
|
|
$rss->_start_element('egms','SubjectCategory'); |
|
41
|
|
|
|
|
|
|
$rss->_newline_if_pretty; |
|
42
|
|
|
|
|
|
|
if ((ref($p->{$elt}) eq 'ARRAY') && (scalar(@{$p->{$elt}}) == 1)) { |
|
43
|
|
|
|
|
|
|
$self->_category_data($rss,${$p->{$elt}}[0]); |
|
44
|
|
|
|
|
|
|
} elsif (ref($p->{$elt}) eq 'ARRAY') { |
|
45
|
|
|
|
|
|
|
$rss->_start_element('rdf','Bag'); |
|
46
|
|
|
|
|
|
|
$rss->_newline_if_pretty; |
|
47
|
|
|
|
|
|
|
foreach my $category (@{$p->{$elt}}) { |
|
48
|
|
|
|
|
|
|
$rss->_start_element('rdf','li'); |
|
49
|
|
|
|
|
|
|
$rss->_newline_if_pretty; |
|
50
|
|
|
|
|
|
|
$self->_category_data($rss,$category); |
|
51
|
|
|
|
|
|
|
$rss->_end_element('rdf','li'); |
|
52
|
|
|
|
|
|
|
$rss->_newline_if_pretty; |
|
53
|
|
|
|
|
|
|
} |
|
54
|
|
|
|
|
|
|
$rss->_end_element('rdf', 'Bag'); |
|
55
|
|
|
|
|
|
|
$rss->_newline_if_pretty; |
|
56
|
|
|
|
|
|
|
} elsif (ref($p->{$elt}) eq 'SCALAR') { |
|
57
|
|
|
|
|
|
|
$self->_generic_category_data($rss,$p->{$elt}); |
|
58
|
|
|
|
|
|
|
} else { |
|
59
|
|
|
|
|
|
|
croak "SubjectCategory data must be an array of arrays or a single scalar\n"; |
|
60
|
|
|
|
|
|
|
} |
|
61
|
|
|
|
|
|
|
$rss->_end_element('egms','SubjectCategory'); |
|
62
|
|
|
|
|
|
|
} else { |
|
63
|
|
|
|
|
|
|
# this is where we should really handle the optional eGMS elements formally... |
|
64
|
|
|
|
|
|
|
$rss->_element_with_data('egms',$elt,$p->{$elt}); |
|
65
|
|
|
|
|
|
|
} |
|
66
|
|
|
|
|
|
|
$rss->_newline_if_pretty; |
|
67
|
|
|
|
|
|
|
} |
|
68
|
|
|
|
|
|
|
} |
|
69
|
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
#### |
|
71
|
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
sub _category_data { |
|
73
|
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
my ($self,$rss,$category) = @_; |
|
75
|
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
if (lc($category->[0]) eq 'ipsv') { |
|
77
|
|
|
|
|
|
|
croak "Can't add IPSV category data without 'ipsv' in your list of modules\n" unless ($rss->{'modules'}{'ipsv'}); |
|
78
|
|
|
|
|
|
|
XML::Generator::RSS10::ipsv->category($rss,$category->[1]); |
|
79
|
|
|
|
|
|
|
} elsif (lc($category->[0]) eq 'gcl') { |
|
80
|
|
|
|
|
|
|
croak "Can't add GCL category data without 'gcl' in your list of modules\n" unless ($rss->{'modules'}{'gcl'}); |
|
81
|
|
|
|
|
|
|
XML::Generator::RSS10::gcl->category($rss,$category->[1]); |
|
82
|
|
|
|
|
|
|
} elsif (lc($category->[0]) eq 'lgcl') { |
|
83
|
|
|
|
|
|
|
croak "Can't add LGCL category data without 'lgcl' in your list of modules\n" unless ($rss->{'modules'}{'lgcl'}); |
|
84
|
|
|
|
|
|
|
XML::Generator::RSS10::lgcl->category($rss,$category->[1]); |
|
85
|
|
|
|
|
|
|
} else { |
|
86
|
|
|
|
|
|
|
$self->_generic_category_data($rss,$category->[1]); |
|
87
|
|
|
|
|
|
|
} |
|
88
|
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
} |
|
90
|
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
#### |
|
92
|
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
sub _generic_category_data { |
|
94
|
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
my ($self,$rss,$category_value) = @_; |
|
96
|
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
$rss->_start_element('egms','SubjectCategoryClass'); |
|
98
|
|
|
|
|
|
|
$rss->_newline_if_pretty; |
|
99
|
|
|
|
|
|
|
$rss->_element_with_data('rdf','value',$category_value); |
|
100
|
|
|
|
|
|
|
$rss->_newline_if_pretty; |
|
101
|
|
|
|
|
|
|
$rss->_end_element('egms','SubjectCategoryClass'); |
|
102
|
|
|
|
|
|
|
$rss->_newline_if_pretty; |
|
103
|
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
} |
|
105
|
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
#### |
|
107
|
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
__END__ |