blib/lib/Net/OAI/Record/NamespaceFilter.pm

filter: Statementstmt 20.9% 37 / 177 Branchbran 7.2% 7 / 96 Conditioncond 9.0% 1 / 11 MC/DCmcdc 0.0% 0 / 7 Subroutinesub 31.5% 6 / 19 Podpod 85.7% 12 / 14 totaltotal 19.4% 63 / 324 SCAR 76.0
CC
57
Cov
16%
start_element
342.0
end_element
210.0
end_prefix_mapping
72.0
CRAP 1993.4
↑ Summary blib/lib/Net/OAI/Record/DocumentHelper.pm »
1 package Net::OAI::Record::NamespaceFilter;
2  
3 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 2 ▶use base qw( XML::SAX::Base );
Subroutine BEGIN: called CC=1 SCAR=0.0
6 2 ▶use Storable;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 2 ▶use Carp qw( carp croak );
Subroutine BEGIN: called CC=1 SCAR=0.0
8 2 our $VERSION = "1.16_12";
9  
10 =head1 NAME
11  
12 Net::OAI::Record::NamespaceFilter - general filter class based on namespace URIs
13  
14 =head1 SYNOPSIS
15  
16 $plug = Net::OAI::Record::NamespaceFilter->new(); # Noop
17  
18 $multihandler = Net::OAI::Record::NamespaceFilter->new(
19 'http://www.openarchives.org/OAI/2.0/oai_dc/' => 'Net::OAI::Record::OAI_DC',
20 'http://www.openarchives.org/OAI/2.0/provenance' => 'MySAX::ProvenanceHandler'
21 );
22  
23 $saxfilter = new SOME_SAX_Filter;
24 ...
25 $filter = Net::OAI::Record::NamespaceFilter->new(
26 '*' => $saxfilter, # '*' for any namespace
27 );
28  
29 $filter = Net::OAI::Record::NamespaceFilter->new(
30 '*' => sub { my $x = "";
31 return XML::SAX::Writer->new(Output => \$x);
32 };
33 );
34  
35  
36  
37 =head1 DESCRIPTION
38  
39 It will forward any element belonging to a namespace from this list
40 to the associated SAX filter and all of the element's children
41 (regardless of their respective namespace) to the same one. It can be used either as a
42 C<metadataHandler> or C<recordHandler>.
43  
44 This SAX filter takes a hashref C<namespaces> as argument, with namespace
45 URIs for keys ('*' for "any namespace") and the values are either
46  
47 =over 4
48  
49 =item undef
50  
51 Matching elements and their subelements are suppressed.
52  
53 If the list of namespaces ist empty or C<undefined> is connected to
54 the filter, it effectively acts as a plug to Net::OAI::Harvester. This
55 might come handy if you are planning to get to the raw result by other
56 means, e.g. by tapping the user agent or accessing the result's xml()
57 method:
58  
59 $plug = Net::OAI::Record::NamespaceFilter->new();
60 $harvester = Net::OAI::Harvester->new( [
61 baseURL => ...,
62 ] );
63  
64 $tapped_by_ua = "";
65 open ($TAP, ">", \$tapped_by_ua);
66 $harvester->userAgent()->add_handler(response_data => sub {
67 my($response, $ua, $h, $data) = @_;
68 print $TAP $data;
69 });
70  
71 $list = $harvester->listRecords(
72 metadataPrefix => 'a_strange_one',
73 recordHandler => $plug,
74 );
75  
76 print $tapped_by_ua; # complete OAI response
77 print $list->xml(); # should be exactly the same
78  
79  
80 Comment: This is quite an efficient way of not processing the XML content
81 of OAI records received.
82  
83  
84 =item a class name of a SAX filter
85  
86 As usual for any record element of the OAI response a new instance is created.
87  
88 # end_document() of instances of MyWriter returns something meaningful...
89 $consumer = Net::OAI::Record::NamespaceFilter->new('*'=> 'MyWriter');
90  
91 $filter = Net::OAI::Record::NamespaceFilter->new(
92 '*' => $consumer
93 );
94
95 $list = $harvester->listAllRecords(
96 metadataPrefix => 'oai_dc',
97 recordHandler => $filter,
98 );
99  
100 while( $r = $list->next() ) {
101 next if $r->status() eq "deleted";
102 $xmlstringref = $r->recorddata()->result('*');
103 ...
104 };
105  
106 Note: The handlers are instantiated for each single OAI record in the response
107 and will see one start_document() and end_document() event in any case (this
108 behavior is different from that of handler class names directly specified as
109 C<metadataHandler> or C<recordHandler> for a request: instances from those
110 constructions will never see such events).
111  
112  
113 =item a code reference for an constructor
114  
115 Must return a SAX filter ready to accept a new document.
116  
117 The following example returns a string serialization for each single
118 record:
119  
120 # end_document() events will return \$x
121 $constructor = sub { my $x = "";
122 return XML::SAX::Writer->new(Output => \$x);
123 };
124 $filter = Net::OAI::Record::NamespaceFilter->new(
125 '*' => $constructor
126 );
127
128 $list = $harvester->listRecords(
129 metadataPrefix => 'oai_dc',
130 recordHandler => $filter,
131 );
132  
133 while( $r = $list->next() ) {
134 $xmlstringref = $r->recorddata()->result('*');
135 ...
136 };
137  
138  
139 Comment: This example shows an approach to insulate the "true contents" of individual
140 response records without having to provide a SAX handler class of one's own (just
141 the addidtional prerequisite of L<XML::SAX::Writer>). But what you get is a
142 serialized XML document which then has to be parsed for further processing ...
143  
144  
145 =item an already instantiated SAX filter
146  
147 As usual in this case no C<start_document()> and C<end_document()> events are
148 forwarded to the filter.
149  
150 open $fh, ">", $some_file;
151 $builder = XML::SAX::Writer->new(Output => $fh);
152 $builder->start_document();
153 $rootEL = { Name => 'collection',
154 LocalName => 'collection',
155 NamespaceURI => "http://www.loc.gov/MARC21/slim",
156 Prefix => "",
157 Attributes => {}
158 };
159 $builder->start_element( $rootEL );
160  
161 # filter for OAI-Namespace in records: forward all
162 $filter = Net::OAI::Record::NamespaceFilter->new(
163 'http://www.loc.gov/MARC21/slim' => $builder);
164  
165 $list = $harvester->listRecords(
166 metadataPrefix => 'a_strange_one',
167 metadataHandler => $filter,
168 );
169 # handle resumption tokens if more than the first
170 # chunk shall be stored into $fh ....
171  
172 $builder->end_element( $rootEL );
173 $builder->end_document();
174 close($fh);
175 # ... process contents of $some_file
176  
177 In this example calling the C<result()> method for individual records in
178 the response will probably not be of much use.
179  
180 =back
181  
182 Caution: Depending on the namespaces specified, even a handlers which
183 are freshly instantiated for each OAI record might be fed with more
184 than one top-level XML element.
185  
186  
187 =head1 METHODS
188  
189 =head2 new( [%namespaces] )
190  
191 Creates a Handler suitable as recordHandler or metadataHandler. %namespaces
192 has namespace B<URIs> for keys and values according to the four types
193 described as above.
194  
195  
196 =cut
197  
198 sub new {
199 4 ▶ my ( $class, %opts ) = @_;
Subroutine new: called CC=6 SCAR=18.0
Pod documented
200 4 ▶ my $self = bless { namespaces => {%opts} }, ref( $class ) || $class;
Condition33%1/3
ref $class || $class
l!l&&r!l&&!r
040
MC/DC0%0/2
ref $class || $class
ref $class $class
Truth table33%1/3
A || B
A= ref $classB= $class
ABresult
1X1
011
000
201 4 $self->{ _activeStack } = [];
202 4 $self->{ _tagStack } = [];
203 4 $self->{ _result } = [];
204 4 $self->{ _prefixmap } = {};
205 4 $self->set_handler( undef );
206 4 delete $self->{ _noHandler }; # follows set_handler()
207 4 $self->{ _handlers } = {};
208 4 $self->{ _performing } = {};
209 4 ▶ while ( my ($key, $value) = each %{$self->{ namespaces }} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = each %{$$self{"namespaces"};}) 3 4 7
210 3 ▶ if ( ! defined $value ) { # no handler
Branch: 3 branches
BranchTrueFalseTotal
if (not defined $value) { } 0 3 3
elsif (not ref $value) { } 1 2 3
elsif (ref $value eq 'CODE') { } 1 1 2
211 0 Net::OAI::Harvester::debug( "new(): case 1 for $key" );
212 }
213 elsif ( ! ref($value) ) { # class name
214 1 Net::OAI::Harvester::debug( "new(): case 2 for $key: $value");
215 1 Net::OAI::Harvester::_verifyHandler( $value );
216 }
217 elsif ( ref($value) eq "CODE" ) { # constructor
218 1 Net::OAI::Harvester::debug( "new(): case 3 for $key");
219 # can't verify now
220 }
221 else { # active instance
222 1 Net::OAI::Harvester::debug( "new(): case 4 for $key" );
223 1 $self->{ _handlers }->{ $key } = $value;
224 1 $self->{ _performing }->{ $value }--;
225 }
226 };
227 4 return( $self );
228 }
229  
230 =head2 result ( [namespace] )
231  
232 If called with a I<namespace>, it returns the result of the handler,
233 i.e. what C<end_document()> returned for the record in question.
234 Otherwise it returns a hashref for all the results with the
235 corresponding namespaces as keys.
236  
237 =cut
238  
239 sub result {
240 0 ▶ my ( $self, $ns ) = @_;
Subroutine result: not called CC=3 SCAR=24.8
Pod documented
241 0 ▶ if ( defined $ns ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $ns) { } 0 0 0
242 0 ▶ return $self->{ _result }->{$ns} || undef}
Condition0%0/2
$self->{'_result'}{$ns} || undef
l!l
00
MC/DC0%0/1
$self->{'_result'}{$ns} || undef
$self->{'_result'}{$ns}
Truth table0%0/2
A
A= $self->{'_result'}{$ns}
Aresult
11
00
243 else {
244 0 return $self->{ _result }}
245 }
246  
247 =head1 AUTHOR
248  
249 Thomas Berger <ThB@gymel.com>
250  
251 =cut
252  
253 ## Storable hooks
254  
255 sub STORABLE_freeze {
256 0 ▶ my ($obj, $cloning) = @_;
Subroutine STORABLE_freeze: not called CC=2 SCAR=17.9
Pod undocumented
257 0 ▶ return if $cloning;
Branch: 1 branch
BranchTrueFalseTotal
if $cloning 0 0 0
258 0 return "", $obj->{ _result }; # || undef;
259 }
260  
261 sub STORABLE_thaw {
262 0 ▶ my ($obj, $cloning, $serialized, $listref) = @_;
Subroutine STORABLE_thaw: not called CC=2 SCAR=17.9
Pod undocumented
263 0 ▶ return if $cloning;
Branch: 1 branch
BranchTrueFalseTotal
if $cloning 0 0 0
264 0 $obj->{ _result } = $listref;
265 #carp "thawed @$listref";
266 }
267  
268  
269 ## SAX handlers
270  
271 sub start_document {
272 0 ▶ my ($self, $document) = @_;
Subroutine start_document: not called CC=1 SCAR=6.9
Pod documented
273 0 carp(<<"XxX");
274 unexpected start_document()
275 0 \t_activeStack: @{$self->{ _activeStack }}
276 0 \t_tagStack: @{$self->{ _tagStack }}
277 XxX
278 0 $self->SUPER::start_document( $document );
279 }
280 sub end_document {
281 0 ▶ my ($self, $document) = @_;
Subroutine end_document: not called CC=1 SCAR=6.9
Pod documented
282 0 carp(<<"XxX");
283 unexpected end_document()
284 0 \t_activeStack: @{$self->{ _activeStack }}
285 0 \t_tagStack: @{$self->{ _tagStack }}
286 XxX
287 0 $self->SUPER::end_document( $document );
288 }
289  
290 sub start_prefix_mapping {
291 0 ▶ my ($self, $mapping) = @_;
Subroutine start_prefix_mapping: not called CC=7 SCAR=40.3
Pod documented
292 0 ▶ $self->SUPER::start_prefix_mapping( $mapping ) unless $self->{ _noHandler };
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"_noHandler"} 0 0 0
293 0 ▶ return if $self->{ _activeStack }->[0];
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"_activeStack"}[0] 0 0 0
294 0 $self->{ _prefixmap }->{ $mapping->{Prefix} } = $mapping;
295 0 my $activehdl = $self->get_handler();
296 0 ▶ croak ("wrong assumption") unless (! defined $activehdl) or $self->{ _performing }->{ $activehdl };
Branch: 1 branch
BranchTrueFalseTotal
unless not defined $activehdl or $self->{"_performing"}{$activehdl} 0 0 0
Condition0%0/3
not defined $activehdl or $self->{"_performing"}{$activehdl}
l!l&&r!l&&!r
000
MC/DC0%0/2
not defined $activehdl or $self->{"_performing"}{$activehdl}
not defined $activehdl $self->{"_performing"}{$activehdl}
Truth table0%0/3
not(A) or B
A= not defined $activehdlB= $self->{"_performing"}{$activehdl}
ABresult
1X1
011
000
297 0 my $switched;
298 0 foreach my $hdl ( keys %{$self->{ _performing }} ) {
299 0 $self->set_handler( $hdl );
300 0 $self->SUPER::start_prefix_mapping( $mapping );
301 0 $switched = 1;
302 }
303 0 ▶ $self->set_handler( $activehdl ) if $switched;
Branch: 1 branch
BranchTrueFalseTotal
if $switched 0 0 0
304 }
305  
306 sub end_prefix_mapping {
307 0 ▶ my ($self, $mapping) = @_;
Subroutine end_prefix_mapping: not called CC=8 SCAR=42.8
Pod documented
308 0 ▶ $self->SUPER::end_prefix_mapping( $mapping ) unless $self->{ _noHandler };
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"_noHandler"} 0 0 0
309 0 ▶ return if $self->{ _activeStack }->[0];
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"_activeStack"}[0] 0 0 0
310 0 ▶ croak ( "mapping @{[%$mapping]} already removed" ) unless $self->{ _prefixmap }->{ $mapping->{Prefix} };
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{"_prefixmap"}{$mapping->{"Prefix"}} 0 0 0
311 0 my $activehdl = $self->get_handler(); # always undef
312 0 ▶ croak ( "wrong assumption" ) unless (! defined $activehdl) or $self->{ _performing }->{ $activehdl };
Branch: 1 branch
BranchTrueFalseTotal
unless not defined $activehdl or $self->{"_performing"}{$activehdl} 0 0 0
Condition0%0/3
not defined $activehdl or $self->{"_performing"}{$activehdl}
l!l&&r!l&&!r
000
MC/DC0%0/2
not defined $activehdl or $self->{"_performing"}{$activehdl}
not defined $activehdl $self->{"_performing"}{$activehdl}
Truth table0%0/3
not(A) or B
A= not defined $activehdlB= $self->{"_performing"}{$activehdl}
ABresult
1X1
011
000
313 0 my $switched;
314 0 foreach my $hdl ( keys %{$self->{ _performing }} ) {
315 0 $self->set_handler( $hdl );
316 0 $self->SUPER::end_prefix_mapping( $mapping );
317 0 $switched = 1;
318 }
319 0 delete $self->{ _prefixmap }->{ $mapping->{Prefix} };
320 0 ▶ $self->set_handler( $activehdl ) if $switched;
Branch: 1 branch
BranchTrueFalseTotal
if $switched 0 0 0
321 }
322  
323 sub start_element {
324 0 ▶ my ( $self, $element ) = @_;
Subroutine start_element: not called CC=18 SCAR=58.3
Pod documented
325 # Net::OAI::Harvester::debug(<<"XxX");
326 #\t((( $element->{ Name } (((
327 #\t\t_activeStack: @{$self->{ _activeStack }}
328 #\t\t_tagStack: @{$self->{ _tagStack }}
329 #XxX
330 0 ▶ if ( $self->{ _activeStack }->[0] ) { # handler already set up
Branch: 1 branch
BranchTrueFalseTotal
if ($self->{'_activeStack'}[0]) { } 0 0 0
331 }
332 else {
333 0 ▶ unless ( $self->{ _tagStack }->[0] ) { # should be the start of a new record
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->{"_tagStack"}[0]) 0 0 0
334 0 $self->{ _result } = {};
335 # start_document here for all defined handlers?
336 0 my $activehdl = $self->get_handler(); # always undef
337 0 ▶ croak( "handler $activehdl already active" ) if defined $activehdl;
Branch: 1 branch
BranchTrueFalseTotal
if defined $activehdl 0 0 0
338 0 my $switched;
339  
340 0 ▶ while ( my ($key, $value) = each %{$self->{ namespaces }} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = each %{$$self{"namespaces"};}) 0 0 0
341 0 $self->{ _result }->{ $key } = undef;
342 0 my $hdl;
343 0 ▶ if ( ! defined $value ) { # no handler
Branch: 3 branches
BranchTrueFalseTotal
if (not defined $value) { } 0 0 0
elsif (not ref $value) { } 0 0 0
elsif (ref $value eq 'CODE') { } 0 0 0
344 # Net::OAI::Harvester::debug( "start_element(): case 1 for $key" );
345 }
346 elsif ( ! ref($value) ) { # class name
347 # Net::OAI::Harvester::debug( "start_element(): case 2 for $key" );
348 0 $hdl = $value->new();
349 }
350 elsif ( ref($value) eq "CODE" ) { # constructor
351 # Net::OAI::Harvester::debug( "start_element(): case 3 for $key" );
352 0 $hdl = &$value();
353 0 Net::OAI::Harvester::_verifyHandler( $hdl );
354 }
355 else { # always active instance
356 # Net::OAI::Harvester::debug( ""start_element(): case 4 for $key. Handler is $value" );
357 0 $switched = 1;
358 0 $self->set_handler( $value );
359 # Those mapping evends *have* already been forwarded... => Bugfix for XML::SAX::Writer?
360 0 foreach my $mapping ( values %{$self->{ _prefixmap }} ) {
361 # Net::OAI::Harvester::debug( "bugfix supply of deferred @{[%$mapping]}" );
362 0 $self->SUPER::start_prefix_mapping( $mapping )}
363 0 next;
364 }
365  
366 0 $self->{ _handlers }->{ $key } = $hdl;
367 0 ▶ next unless defined $hdl;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $hdl 0 0 0
368 0 ▶ next if $self->{ _performing }->{ $hdl }++;
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"_performing"}{$hdl}++ 0 0 0
369 0 $switched = 1;
370 0 $self->set_handler( $hdl );
371 0 $self->SUPER::start_document({});
372 0 foreach my $mapping ( values %{$self->{ _prefixmap }} ) {
373 0 $self->SUPER::start_prefix_mapping( $mapping )}
374 }
375 0 ▶ $self->set_handler( $activehdl ) if $switched;
Branch: 1 branch
BranchTrueFalseTotal
if $switched 0 0 0
376 };
377  
378 0 ▶ if ( exists $self->{ namespaces }->{$element->{ NamespaceURI }} ) {
Branch: 2 branches
BranchTrueFalseTotal
if (exists $self->{'namespaces'}{$element->{'NamespaceURI'}}) { } 0 0 0
elsif (exists $self->{'namespaces'}{'*'}) { } 0 0 0
379 0 ▶ if ( defined (my $hdl = $self->{ _handlers }->{$element->{ NamespaceURI }}) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined(my $hdl = $self->{"_handlers"}{$element->{"NamespaceURI"}})) 0 0 0
380 0 $self->set_handler( $hdl );
381 0 $self->{ _noHandler } = 0;
382 };
383 }
384 elsif ( exists $self->{ namespaces }->{'*'} ) {
385 0 ▶ if ( defined (my $hdl = $self->{ _handlers }->{'*'}) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined(my $hdl = $self->{"_handlers"}{"*"})) 0 0 0
386 0 $self->set_handler( $hdl );
387 0 $self->{ _noHandler } = 0;
388 };
389 }
390 else {
391 0 push (@{$self->{ _tagStack }}, $element->{ Name });
392 0 return;
393 };
394 };
395  
396 0 push (@{$self->{ _activeStack }}, $element->{ Name });
397 0 ▶ return if $self->{ _noHandler };
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"_noHandler"} 0 0 0
398 0 $self->SUPER::start_element( $element );
399 }
400  
401 sub end_element {
402 0 ▶ my ( $self, $element ) = @_;
Subroutine end_element: not called CC=14 SCAR=53.5
Pod documented
403 # Net::OAI::Harvester::debug(<<"XxX");
404 #\t))) $element->{ Name } )))
405 #\t\t_activeStack: @{$self->{ _activeStack }}
406 #\t\t_tagStack: @{$self->{ _tagStack }}
407 #XxX
408 0 ▶ if ( $self->{ _activeStack }->[0] ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($self->{'_activeStack'}[0]) { } 0 0 0
elsif ($self->{'_tagStack'}[0]) { } 0 0 0
409 0 ▶ unless ( $self->{ _noHandler } ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->{"_noHandler"}) 0 0 0
410 0 $self->SUPER::end_element( $element );
411 };
412 0 pop (@{$self->{ _activeStack }});
413 0 ▶ return if $self->{ _activeStack }->[0];
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"_activeStack"}[0] 0 0 0
414 0 ▶ unless ( $self->{ _noHandler } ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->{"_noHandler"}) 0 0 0
415 0 $self->set_handler(undef);
416 0 $self->{ _noHandler } = 1;
417 }
418 }
419 elsif ( $self->{ _tagStack }->[0] ) {
420 0 pop (@{$self->{ _tagStack }});
421 }
422 0 ▶ return if $self->{ _tagStack }->[0];
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"_tagStack"}[0] 0 0 0
423 0 my $activehdl = $self->get_handler(); # always undef
424 0 ▶ croak ( "handler $activehdl still active" ) if defined $activehdl;
Branch: 1 branch
BranchTrueFalseTotal
if defined $activehdl 0 0 0
425 0 my $switched;
426 0 ▶ while ( my ($key, $value) = each %{$self->{ namespaces }} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = each %{$$self{"namespaces"};}) 0 0 0
427 0 ▶ if ( ! defined $value ) {
Branch: 2 branches
BranchTrueFalseTotal
if (not defined $value) { } 0 0 0
elsif (my $hdl = $self->{'_handlers'}{$key}) { } 0 0 0
428 # Net::OAI::Harvester::debug( "end_element(): case 1 for $key" );
429 0 $self->{ _result }->{ $key } = "";
430 }
431 elsif ( my $hdl = $self->{ _handlers }->{ $key } ) {
432 0 ▶ if ( ! $self->{ _performing }->{ $hdl } ) {
Branch: 2 branches
BranchTrueFalseTotal
if (not $self->{'_performing'}{$hdl}) { } 0 0 0
elsif ($self->{'_performing'}{$hdl} < 0) { } 0 0 0
433 0 carp "already(?) inactive handler $hdl for $key";
434 0 delete $self->{ _handlers }->{ $key };
435 0 next;
436 }
437 elsif ( $self->{ _performing }->{ $hdl } < 0 ) { # always active handler
438 # Net::OAI::Harvester::debug( "end_element(): case 4 for $key" );
439 0 $self->{ _result }->{ $key } = undef;
440 0 next;
441 };
442 # Net::OAI::Harvester::debug( "end_element(): case 2/3 for $key" );
443 0 delete $self->{ _handlers }->{ $key };
444 0 delete $self->{ _performing }->{ $hdl };
445 0 $switched = 1;
446 0 $self->set_handler( $hdl );
447 # revoke some stored namespace mappings, too?
448 0 my $result = $self->SUPER::end_document({});
449 0 $self->{ _result }->{ $key } = $result;
450 }
451 else {
452 0 croak("Assertion failed: $key not listed as _handler");
453 };
454 };
455 0 ▶ $self->set_handler( $activehdl ) if $switched;
Branch: 1 branch
BranchTrueFalseTotal
if $switched 0 0 0
456 }
457  
458 sub characters {
459 0 ▶ my ( $self, $characters ) = @_;
Subroutine characters: not called CC=2 SCAR=17.9
Pod documented
460 0 ▶ return if $self->{ _noHandler };
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"_noHandler"} 0 0 0
461 0 return $self->SUPER::characters( $characters );
462 }
463  
464 sub ignorable_whitespace {
465 0 ▶ my ( $self, $characters ) = @_;
Subroutine ignorable_whitespace: not called CC=2 SCAR=17.9
Pod documented
466 0 ▶ return if $self->{ _noHandler };
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"_noHandler"} 0 0 0
467 0 return $self->SUPER::ignorable_whitespace( $characters );
468 }
469  
470 sub comment {
471 0 ▶ my ( $self, $comment ) = @_;
Subroutine comment: not called CC=2 SCAR=17.9
Pod documented
472 0 ▶ return if $self->{ _noHandler };
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"_noHandler"} 0 0 0
473 0 return $self->SUPER::comment( $comment );
474 }
475  
476 sub processing_instruction {
477 0 ▶ my ( $self, $pi ) = @_;
Subroutine processing_instruction: not called CC=2 SCAR=17.9
Pod documented
478 0 ▶ return if $self->{ _noHandler };
Branch: 1 branch
BranchTrueFalseTotal
if $self->{"_noHandler"} 0 0 0
479 0 return $self->SUPER::processing_instruction( $pi );
480 }
481  
482 2 1;
483  
↑ Summary blib/lib/Net/OAI/Record/DocumentHelper.pm »