line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Catmandu::Importer::SRU::Parser; |
2
|
|
|
|
|
|
|
|
3
|
8
|
|
|
8
|
|
53
|
use Moo; |
|
8
|
|
|
|
|
15
|
|
|
8
|
|
|
|
|
45
|
|
4
|
8
|
|
|
8
|
|
5228
|
use XML::LibXML::Simple qw(XMLin); |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
our $VERSION = '0.040'; |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
sub parse { |
9
|
|
|
|
|
|
|
my ($self,$record) = @_; |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
return unless defined $record; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
# By default we use XML::LibXML::Simple to keep backwards compatible... |
14
|
|
|
|
|
|
|
my $xs = XML::LibXML::Simple->new(); |
15
|
|
|
|
|
|
|
$record->{recordData} = $xs->XMLin($record->{recordData} , KeepRoot => 1, NsStrip => 1); |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
$record; |
18
|
|
|
|
|
|
|
} |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
=head1 NAME |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
Catmandu::Importer::SRU::Parser - Package transforms SRU responses into Perl |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
=head1 SYNOPSIS |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
package MyParser; |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
use Moo; |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
sub parse { |
31
|
|
|
|
|
|
|
my ($self,$record) = @_; |
32
|
|
|
|
|
|
|
my $schema = $record->{recordSchema}; |
33
|
|
|
|
|
|
|
my $packing = $record->{recordPacking}; |
34
|
|
|
|
|
|
|
my $data = $record->{recordData}; |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
... do some magic... |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
return $perl_hash; |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
=head1 DESCRIPTION |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
Catmandu::Importer::SRU can optionally include a parser to transform the |
44
|
|
|
|
|
|
|
returned records from SRU requests. Any such parser needs to implement one |
45
|
|
|
|
|
|
|
instance method 'parse' which receives an SRU-record and returns a perl hash; |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
=head1 AUTHOR |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
Patrick Hochstenbach, C<< <patrick.hochstenbach at ugent.be> >> |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
=cut |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
1; |