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