| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Net::OAI::Record::Header; |
|
2
|
|
|
|
|
|
|
|
|
3
|
16
|
|
|
16
|
|
75
|
use strict; |
|
|
16
|
|
|
|
|
25
|
|
|
|
16
|
|
|
|
|
408
|
|
|
4
|
16
|
|
|
16
|
|
75
|
use base qw( XML::SAX::Base ); |
|
|
16
|
|
|
|
|
25
|
|
|
|
16
|
|
|
|
|
1025
|
|
|
5
|
16
|
|
|
16
|
|
83
|
use Carp qw( carp ); |
|
|
16
|
|
|
|
|
34
|
|
|
|
16
|
|
|
|
|
17140
|
|
|
6
|
|
|
|
|
|
|
our $VERSION = 'v1.016.010'; |
|
7
|
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
=head1 NAME |
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
Net::OAI::Record::Header - class for record header representation |
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
16
|
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
Actually this class implements a SAX filter for the |
|
18
|
|
|
|
|
|
|
complete C OAI-PMH element. The contents of the C |
|
19
|
|
|
|
|
|
|
child are collected into a header object and can be accessed by the |
|
20
|
|
|
|
|
|
|
methods documented here. |
|
21
|
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
Events will be traditionally forwarded only from the subelement(s) of |
|
23
|
|
|
|
|
|
|
the C child which makes it difficult to access data |
|
24
|
|
|
|
|
|
|
contained in the (possibly multiple) C containers which may follow |
|
25
|
|
|
|
|
|
|
the C in the C. |
|
26
|
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
Beginning from OAI-Harvester v1.17 a new "recordHandler" argument |
|
28
|
|
|
|
|
|
|
may be given to the harvester functions C and C: |
|
29
|
|
|
|
|
|
|
In contrast to a "metadataHandler" argument this will pass the "fwdAll" |
|
30
|
|
|
|
|
|
|
argument to the constructor of this Header class and result in |
|
31
|
|
|
|
|
|
|
forwarding all events in the C (including C itself) to |
|
32
|
|
|
|
|
|
|
the handler specified, not only those from C children. |
|
33
|
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
The SAX filter implemented by this class purposefully does not generate |
|
35
|
|
|
|
|
|
|
any start_document() or end_document() events. |
|
36
|
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
=head1 METHODS |
|
39
|
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
=head2 new() |
|
41
|
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
=cut |
|
43
|
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
sub new { |
|
45
|
6409
|
|
|
6409
|
1
|
33905
|
my ( $class, %opts ) = @_; |
|
46
|
6409
|
|
33
|
|
|
27889
|
my $self = bless \%opts, ref( $class ) || $class; |
|
47
|
6409
|
|
|
|
|
19045
|
$self->{ status } = $self->{ identifier } = $self->{ datestamp } = ''; |
|
48
|
6409
|
|
|
|
|
11570
|
$self->{ _tagStack } = []; |
|
49
|
6409
|
|
|
|
|
11307
|
$self->{ sets } = []; |
|
50
|
6409
|
|
|
|
|
18757
|
$self->{ _insideHeader } = $self->{ _insideMetadata } = $self->{ _insideAbout } = 0; |
|
51
|
6409
|
|
|
|
|
21417
|
return( $self ); |
|
52
|
|
|
|
|
|
|
} |
|
53
|
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
=head2 status() |
|
55
|
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
Gets the optional C attribute of the OAI header and returns either "deleted" or "". |
|
57
|
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
=cut |
|
59
|
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
sub status { |
|
61
|
3
|
|
|
3
|
1
|
487
|
my ( $self, $status ) = @_; |
|
62
|
3
|
100
|
|
|
|
10
|
if ( $status ) { $self->{ headerStatus } = $status; } |
|
|
1
|
|
|
|
|
3
|
|
|
63
|
3
|
|
|
|
|
12
|
return( $self->{ headerStatus } ); |
|
64
|
|
|
|
|
|
|
} |
|
65
|
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
=head2 identifier() |
|
67
|
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
=cut |
|
69
|
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
sub identifier { |
|
71
|
5007
|
|
|
5007
|
1
|
1045000
|
my ( $self, $id ) = @_; |
|
72
|
5007
|
100
|
|
|
|
11769
|
if ( $id ) { $self->{ identifier } = $id; } |
|
|
1
|
|
|
|
|
3
|
|
|
73
|
5007
|
|
|
|
|
17558
|
return( $self->{ identifier } ); |
|
74
|
|
|
|
|
|
|
} |
|
75
|
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
=head2 datestamp() |
|
77
|
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
=cut |
|
79
|
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
sub datestamp { |
|
81
|
2
|
|
|
2
|
1
|
4
|
my ( $self, $datestamp ) = @_; |
|
82
|
2
|
100
|
|
|
|
7
|
if ( $datestamp ) { $self->{ datestamp } = $datestamp; } |
|
|
1
|
|
|
|
|
2
|
|
|
83
|
2
|
|
|
|
|
8
|
return( $self->{ datestamp } ); |
|
84
|
|
|
|
|
|
|
} |
|
85
|
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
=head2 setSpecs() |
|
87
|
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
=head2 sets() DEPRECATED |
|
89
|
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
=cut |
|
91
|
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
sub setSpecs { |
|
93
|
1002
|
|
|
1002
|
1
|
2100
|
my ( $self, @sets ) = @_; |
|
94
|
1002
|
100
|
|
|
|
2497
|
if ( @sets ) { $self->{ sets } = \@sets; } |
|
|
1
|
|
|
|
|
3
|
|
|
95
|
1002
|
|
|
|
|
1408
|
return( @{ $self->{ sets } } ); |
|
|
1002
|
|
|
|
|
3693
|
|
|
96
|
|
|
|
|
|
|
} |
|
97
|
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
sub sets { |
|
99
|
0
|
|
|
0
|
1
|
0
|
return setSpecs(@_); |
|
100
|
|
|
|
|
|
|
} |
|
101
|
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
## SAX Handlers |
|
103
|
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
sub start_prefix_mapping { |
|
105
|
7037
|
|
|
7037
|
1
|
63584
|
my ($self, $mapping) = @_; |
|
106
|
7037
|
50
|
|
|
|
17208
|
if ( $self->get_handler() ) { |
|
107
|
7037
|
|
|
|
|
59071
|
return $self->SUPER::start_prefix_mapping( $mapping )}; |
|
108
|
0
|
|
|
|
|
0
|
die "HEADER: would have to buffer @{[$mapping]}"; |
|
|
0
|
|
|
|
|
0
|
|
|
109
|
|
|
|
|
|
|
} |
|
110
|
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
sub start_element { |
|
112
|
64933
|
|
|
64933
|
1
|
461863
|
my ( $self, $element ) = @_; |
|
113
|
64933
|
100
|
|
|
|
159767
|
unless ( $element->{ NamespaceURI } eq Net::OAI::Harvester::XMLNS_OAI ) { |
|
114
|
32935
|
50
|
66
|
|
|
156319
|
$self->SUPER::start_element($element) if $self->{ fwdAll } or $self->{ _insideMetadata }; |
|
115
|
32935
|
|
|
|
|
772836
|
return; |
|
116
|
|
|
|
|
|
|
} |
|
117
|
|
|
|
|
|
|
|
|
118
|
31998
|
|
|
|
|
46420
|
my $tagName = $element->{ LocalName }; |
|
119
|
31998
|
|
|
|
|
36417
|
push( @{$self->{ _tagStack }}, $tagName ); |
|
|
31998
|
|
|
|
|
70481
|
|
|
120
|
31998
|
100
|
|
|
|
109109
|
if ( $tagName eq 'record' ) { |
|
|
|
100
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
121
|
1408
|
|
|
|
|
2914
|
$self->{ _insideHeader } = $self->{ _insideMetadata } = $self->{ _insideAbout } = 0} |
|
122
|
|
|
|
|
|
|
elsif ( $tagName eq 'header' ) { |
|
123
|
6408
|
|
|
|
|
9590
|
$self->{ _insideHeader } = 1; |
|
124
|
|
|
|
|
|
|
$self->{ headerStatus } = ( exists $element->{ Attributes }{ '{}status' } ) |
|
125
|
|
|
|
|
|
|
? $element->{ Attributes }{ '{}status' }{ Value } |
|
126
|
6408
|
100
|
|
|
|
17611
|
: ""; |
|
127
|
|
|
|
|
|
|
} |
|
128
|
|
|
|
|
|
|
elsif ( $self->{ _insideHeader } ) { |
|
129
|
|
|
|
|
|
|
} |
|
130
|
|
|
|
|
|
|
elsif ( $tagName eq 'metadata' ) { |
|
131
|
1407
|
|
|
|
|
2467
|
$self->{ _insideMetadata } = 1; |
|
132
|
|
|
|
|
|
|
} |
|
133
|
|
|
|
|
|
|
elsif ( $tagName eq 'about' ) { |
|
134
|
0
|
|
|
|
|
0
|
$self->{ _insideAbout } = 1; |
|
135
|
|
|
|
|
|
|
} |
|
136
|
|
|
|
|
|
|
else { |
|
137
|
0
|
|
|
|
|
0
|
carp "who am I? ($tagName)"; |
|
138
|
0
|
|
|
|
|
0
|
return $self->SUPER::start_element($element); |
|
139
|
|
|
|
|
|
|
}; |
|
140
|
31998
|
100
|
|
|
|
171484
|
return $self->SUPER::start_element($element) if $self->{ fwdAll }; |
|
141
|
|
|
|
|
|
|
} |
|
142
|
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
sub end_element { |
|
144
|
64933
|
|
|
64933
|
1
|
452754
|
my ( $self, $element ) = @_; |
|
145
|
64933
|
100
|
|
|
|
156946
|
unless ( $element->{ NamespaceURI } eq Net::OAI::Harvester::XMLNS_OAI ) { |
|
146
|
32935
|
50
|
66
|
|
|
153788
|
$self->SUPER::end_element($element) if $self->{ fwdAll } or $self->{ _insideMetadata }; |
|
147
|
32935
|
|
|
|
|
197282
|
return; |
|
148
|
|
|
|
|
|
|
} |
|
149
|
|
|
|
|
|
|
|
|
150
|
31998
|
|
|
|
|
34305
|
pop( @{$self->{ _tagStack }} ); |
|
|
31998
|
|
|
|
|
60086
|
|
|
151
|
31998
|
|
|
|
|
56055
|
my $tagName = $element->{ LocalName }; |
|
152
|
31998
|
100
|
|
|
|
96452
|
if ( $tagName eq 'header' ) { |
|
|
|
100
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
153
|
6408
|
|
|
|
|
9606
|
$self->{ _insideHeader } = 0; |
|
154
|
6408
|
50
|
33
|
|
|
42457
|
(defined $self->{header}) && ($self->{header} =~ /\S/) && carp "Excess content in record header: ".$self->{ header }; |
|
155
|
|
|
|
|
|
|
} |
|
156
|
|
|
|
|
|
|
elsif ( $tagName eq 'setSpec' ) { |
|
157
|
9959
|
|
|
|
|
11219
|
push( @{ $self->{ sets } }, $self->{ setSpec } ); |
|
|
9959
|
|
|
|
|
26114
|
|
|
158
|
|
|
|
|
|
|
} |
|
159
|
|
|
|
|
|
|
elsif ( $self->{ _insideHeader } ) { |
|
160
|
|
|
|
|
|
|
} |
|
161
|
|
|
|
|
|
|
elsif ( $tagName eq 'metadata' ) { |
|
162
|
1407
|
|
|
|
|
2976
|
$self->{ _insideMetadata } = 0; |
|
163
|
|
|
|
|
|
|
} |
|
164
|
|
|
|
|
|
|
elsif ( $tagName eq 'about' ) { |
|
165
|
0
|
|
|
|
|
0
|
$self->{ _insideAbout } = 0; |
|
166
|
|
|
|
|
|
|
} |
|
167
|
|
|
|
|
|
|
elsif ( $tagName eq 'record' ) { |
|
168
|
1408
|
|
|
|
|
2735
|
delete $self->{ _insideHeader }; |
|
169
|
1408
|
|
|
|
|
2301
|
delete $self->{ _insideMetadata }; |
|
170
|
1408
|
|
|
|
|
2219
|
delete $self->{ _insideAbout }; |
|
171
|
1408
|
|
|
|
|
2829
|
delete $self->{ _tagStack }; |
|
172
|
|
|
|
|
|
|
} |
|
173
|
|
|
|
|
|
|
else { |
|
174
|
0
|
|
|
|
|
0
|
carp "who am I? ($tagName)"; |
|
175
|
0
|
|
|
|
|
0
|
return $self->SUPER::end_element( $element ); |
|
176
|
|
|
|
|
|
|
}; |
|
177
|
31998
|
100
|
|
|
|
128047
|
return $self->SUPER::end_element($element) if $self->{ fwdAll }; |
|
178
|
|
|
|
|
|
|
} |
|
179
|
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
|
|
181
|
|
|
|
|
|
|
sub ignorable_whitespace { |
|
182
|
0
|
|
|
0
|
1
|
0
|
my ( $self, $characters ) = @_; |
|
183
|
0
|
0
|
0
|
|
|
0
|
return $self->SUPER::ignorable_whitespace( $characters ) if $self->{ fwdAll } or $self->{ _insideMetadata }; |
|
184
|
|
|
|
|
|
|
} |
|
185
|
|
|
|
|
|
|
|
|
186
|
|
|
|
|
|
|
sub characters { |
|
187
|
130713
|
|
|
130713
|
1
|
1271781
|
my ( $self, $characters ) = @_; |
|
188
|
130713
|
100
|
|
|
|
412730
|
$self->{ $self->{ _tagStack }[-1] } .= $characters->{ Data } if $self->{ _insideHeader }; |
|
189
|
130713
|
100
|
66
|
|
|
705442
|
return $self->SUPER::characters( $characters ) if $self->{ fwdAll } or $self->{ _insideMetadata }; |
|
190
|
|
|
|
|
|
|
} |
|
191
|
|
|
|
|
|
|
|
|
192
|
|
|
|
|
|
|
1; |
|
193
|
|
|
|
|
|
|
|