line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Catmandu::AlephX::Metadata::MARC; |
2
|
3
|
|
|
3
|
|
105493
|
use Catmandu::Sane; |
|
3
|
|
|
|
|
198150
|
|
|
3
|
|
|
|
|
20
|
|
3
|
3
|
|
|
3
|
|
610
|
use Moo; |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
16
|
|
4
|
|
|
|
|
|
|
extends qw(Catmandu::AlephX::Metadata); |
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
our $VERSION = "1.073"; |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
#parse marcxml into Catmandu marc array |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
sub parse { |
11
|
0
|
|
|
0
|
0
|
|
my($class,$xpath)=@_; |
12
|
|
|
|
|
|
|
|
13
|
0
|
|
|
|
|
|
my @marc = (); |
14
|
|
|
|
|
|
|
|
15
|
0
|
|
|
|
|
|
my $leader = $xpath->findvalue("./*[local-name() = 'leader']"); |
16
|
0
|
|
|
|
|
|
my $fmt = ""; |
17
|
0
|
|
|
|
|
|
my $_id; |
18
|
|
|
|
|
|
|
|
19
|
0
|
|
|
|
|
|
for my $controlfield($xpath->find("./*[local-name() = 'controlfield']")->get_nodelist()){ |
20
|
0
|
|
|
|
|
|
my $tag = $controlfield->findvalue('@tag'); |
21
|
0
|
|
|
|
|
|
my $value = $controlfield->findvalue('.'); |
22
|
0
|
0
|
|
|
|
|
if($tag eq "FMT"){ |
23
|
0
|
|
|
|
|
|
$fmt = $value; |
24
|
0
|
|
|
|
|
|
next; |
25
|
|
|
|
|
|
|
} |
26
|
0
|
0
|
|
|
|
|
if($tag eq "001"){ |
|
|
0
|
|
|
|
|
|
27
|
0
|
|
|
|
|
|
$_id = $value; |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
#leader can also be specified in a controlfield?? |
30
|
|
|
|
|
|
|
elsif($tag eq "LDR"){ |
31
|
0
|
|
|
|
|
|
$leader = $value; |
32
|
0
|
|
|
|
|
|
next; |
33
|
|
|
|
|
|
|
} |
34
|
0
|
|
|
|
|
|
push @marc,[$tag,'','','_',$value]; |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
|
37
|
0
|
|
|
|
|
|
unshift @marc,['FMT','','','_',$fmt],['LDR','','','_',$leader]; |
38
|
|
|
|
|
|
|
|
39
|
0
|
|
|
|
|
|
for my $datafield($xpath->find("./*[local-name() = 'datafield']")->get_nodelist()){ |
40
|
|
|
|
|
|
|
|
41
|
0
|
|
|
|
|
|
my $tag = $datafield->findvalue('@tag'); |
42
|
0
|
|
|
|
|
|
my $ind1 = $datafield->findvalue('@ind1'); |
43
|
0
|
|
|
|
|
|
my $ind2 = $datafield->findvalue('@ind2'); |
44
|
|
|
|
|
|
|
|
45
|
0
|
|
|
|
|
|
my @subf = (); |
46
|
|
|
|
|
|
|
|
47
|
0
|
|
|
|
|
|
foreach my $subfield($datafield->find("./*[local-name() = 'subfield']")->get_nodelist()) { |
48
|
0
|
|
|
|
|
|
my $code = $subfield->findvalue('@code'); |
49
|
0
|
|
|
|
|
|
my $value = $subfield->findvalue('.'); |
50
|
0
|
|
|
|
|
|
push @subf,$code,$value; |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
|
53
|
0
|
|
|
|
|
|
push @marc,[$tag,$ind1,$ind2,@subf]; |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
|
57
|
0
|
|
|
|
|
|
__PACKAGE__->new(type => 'oai_marc',data => { record => \@marc, _id => $_id }); |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
1; |