line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Net::OAI::Record::OAI_DC; |
2
|
|
|
|
|
|
|
|
3
|
17
|
|
|
17
|
|
88
|
use strict; |
|
17
|
|
|
|
|
29
|
|
|
17
|
|
|
|
|
431
|
|
4
|
17
|
|
|
17
|
|
77
|
use warnings; |
|
17
|
|
|
|
|
32
|
|
|
17
|
|
|
|
|
439
|
|
5
|
17
|
|
|
17
|
|
83
|
use base qw( XML::SAX::Base ); |
|
17
|
|
|
|
|
29
|
|
|
17
|
|
|
|
|
1162
|
|
6
|
17
|
|
|
17
|
|
84
|
use Carp qw( carp ); |
|
17
|
|
|
|
|
29
|
|
|
17
|
|
|
|
|
1256
|
|
7
|
|
|
|
|
|
|
our $VERSION = "1.16_12"; |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
use constant { |
10
|
17
|
|
|
|
|
13362
|
XMLNS_DC => 'http://purl.org/dc/elements/1.1/', |
11
|
|
|
|
|
|
|
XMLNS_OAIDC => 'http://www.openarchives.org/OAI/2.0/oai_dc/', |
12
|
17
|
|
|
17
|
|
87
|
}; |
|
17
|
|
|
|
|
27
|
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
our @OAI_DC_ELEMENTS = qw( |
15
|
|
|
|
|
|
|
title |
16
|
|
|
|
|
|
|
creator |
17
|
|
|
|
|
|
|
subject |
18
|
|
|
|
|
|
|
description |
19
|
|
|
|
|
|
|
publisher |
20
|
|
|
|
|
|
|
contributor |
21
|
|
|
|
|
|
|
date |
22
|
|
|
|
|
|
|
type |
23
|
|
|
|
|
|
|
format |
24
|
|
|
|
|
|
|
identifier |
25
|
|
|
|
|
|
|
source |
26
|
|
|
|
|
|
|
language |
27
|
|
|
|
|
|
|
relation |
28
|
|
|
|
|
|
|
coverage |
29
|
|
|
|
|
|
|
rights |
30
|
|
|
|
|
|
|
); |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
our $AUTOLOAD; |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
=head1 NAME |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
Net::OAI::Record::OAI_DC - class for baseline Dublin Core support |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
=head1 SYNOPSIS |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
=head1 DESCRIPTION |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
=head1 METHODS |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
The accessor methods are aware of their calling context (list,scalar) and |
45
|
|
|
|
|
|
|
will respond appropriately. For example an item may have multiple creators, |
46
|
|
|
|
|
|
|
so a call to creator() in a scalar context returns only the first creator; |
47
|
|
|
|
|
|
|
and in a list context all creators are returned. |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
# scalar context |
50
|
|
|
|
|
|
|
my $creator = $metadata->creator(); |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
# list context |
53
|
|
|
|
|
|
|
my @creators = $metadata->creator(); |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
=head2 new() |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
=cut |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
sub new { |
60
|
602
|
|
|
602
|
1
|
1255
|
my ( $class, %opts ) = @_; |
61
|
602
|
|
33
|
|
|
3103
|
my $self = bless \%opts, ref( $class ) || $class; |
62
|
602
|
|
|
|
|
1391
|
foreach ( @OAI_DC_ELEMENTS ) { $self->{ $_ } = []; } |
|
9030
|
|
|
|
|
20522
|
|
63
|
602
|
|
|
|
|
3973
|
return( $self ); |
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
=head2 title() |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
=head2 creator() |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
=head2 subject() |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
=head2 description() |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
=head2 publisher() |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
=head2 contributor() |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
=head2 date() |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
=head2 type() |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
=head2 format() |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
=head2 identifier() |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
=head2 source() |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
=head2 language() |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
=head2 relation() |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
=head2 coverage() |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
=head2 rights() |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
=cut |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
## rather than right all the accessors we use AUTOLOAD to catch calls |
99
|
|
|
|
|
|
|
## valid element names as methods, and return appropriately as a list |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
sub AUTOLOAD { |
102
|
603
|
|
|
603
|
|
91122
|
my $self = shift; |
103
|
603
|
|
|
|
|
1249
|
my $sub = lc( $AUTOLOAD ); |
104
|
603
|
|
|
|
|
2497
|
$sub =~ s/.*:://; |
105
|
603
|
50
|
|
|
|
5618
|
if ( grep /$sub/, @OAI_DC_ELEMENTS ) { |
106
|
603
|
50
|
|
|
|
1215
|
if ( wantarray() ) { |
107
|
0
|
|
|
|
|
0
|
return( @{ $self->{ $sub } } ); |
|
0
|
|
|
|
|
0
|
|
108
|
|
|
|
|
|
|
} else { |
109
|
603
|
|
|
|
|
2984
|
return( $self->{ $sub }[0] ); |
110
|
|
|
|
|
|
|
} |
111
|
|
|
|
|
|
|
} |
112
|
|
|
|
|
|
|
} |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
## generic output method |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
sub asString { |
117
|
0
|
|
|
0
|
0
|
0
|
my $self = shift; |
118
|
0
|
|
|
|
|
0
|
my @result; |
119
|
0
|
|
|
|
|
0
|
foreach my $element ( @OAI_DC_ELEMENTS ) { |
120
|
0
|
0
|
|
|
|
0
|
next unless $self->{ $element }; |
121
|
0
|
|
|
|
|
0
|
foreach ( @{ $self->{ $element } } ) { |
|
0
|
|
|
|
|
0
|
|
122
|
0
|
|
|
|
|
0
|
push(@result, "$element => $_"); |
123
|
|
|
|
|
|
|
} |
124
|
|
|
|
|
|
|
} |
125
|
0
|
|
|
|
|
0
|
return join("\n", @result); |
126
|
|
|
|
|
|
|
} |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
## SAX handlers |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
sub start_element { |
131
|
12657
|
|
|
12657
|
1
|
84093
|
my ( $self, $element ) = @_; |
132
|
12657
|
|
|
|
|
20592
|
my $elname = $element->{ LocalName }; |
133
|
12657
|
100
|
66
|
|
|
194619
|
if ( ($element->{ NamespaceURI } eq XMLNS_OAIDC) and ($elname eq "dc") ) { |
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
134
|
601
|
|
|
|
|
2433
|
$self->{ _insideRecord } = 1} |
135
|
|
|
|
|
|
|
elsif ( $element->{ NamespaceURI } ne XMLNS_DC ) { |
136
|
0
|
|
|
|
|
0
|
carp "what is ".$element->{ Name }."?"; |
137
|
0
|
|
|
|
|
0
|
return undef; |
138
|
|
|
|
|
|
|
} |
139
|
|
|
|
|
|
|
elsif ( grep /$elname/, @OAI_DC_ELEMENTS ) { |
140
|
12056
|
|
|
|
|
43239
|
$self->{ chars } = ""} |
141
|
|
|
|
|
|
|
else { |
142
|
0
|
|
|
|
|
0
|
carp "what is $elname?"} |
143
|
|
|
|
|
|
|
} |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
sub end_element { |
146
|
12657
|
|
|
12657
|
1
|
83816
|
my ( $self, $element ) = @_; |
147
|
12657
|
|
|
|
|
20174
|
my $elname = $element->{ LocalName }; |
148
|
|
|
|
|
|
|
|
149
|
12657
|
100
|
66
|
|
|
184685
|
if ( ($element->{ NamespaceURI } eq XMLNS_OAIDC) and ($elname eq "dc") ) { |
|
|
50
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
150
|
601
|
|
|
|
|
2089
|
$self->{ _insideRecord } = 0} |
151
|
|
|
|
|
|
|
elsif ( $element->{ NamespaceURI } ne XMLNS_DC ) { |
152
|
0
|
|
|
|
|
0
|
return undef} |
153
|
|
|
|
|
|
|
elsif ( grep /$elname/, @OAI_DC_ELEMENTS ) { # o.k. |
154
|
12056
|
|
|
|
|
14169
|
push( @{ $self->{ $elname } }, $self->{ chars } ); |
|
12056
|
|
|
|
|
41151
|
|
155
|
12056
|
|
|
|
|
40742
|
$self->{ chars } = undef; |
156
|
|
|
|
|
|
|
} |
157
|
|
|
|
|
|
|
elsif ( $self->{ chars } =~ /\S/ ) { |
158
|
0
|
|
|
|
|
0
|
carp "unassigned content: ".$self->{ chars }; |
159
|
|
|
|
|
|
|
} |
160
|
|
|
|
|
|
|
} |
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
sub characters { |
163
|
28763
|
|
|
28763
|
1
|
177119
|
my ( $self, $characters ) = @_; |
164
|
28763
|
100
|
|
|
|
182514
|
$self->{ chars } .= $characters->{ Data } if $self->{ _insideRecord }; |
165
|
|
|
|
|
|
|
} |
166
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
1; |
168
|
|
|
|
|
|
|
|