line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Catmandu::Fix::marc_xml; |
2
|
|
|
|
|
|
|
|
3
|
3
|
|
|
3
|
|
83404
|
use Catmandu::Sane; |
|
3
|
|
|
|
|
136735
|
|
|
3
|
|
|
|
|
19
|
|
4
|
3
|
|
|
3
|
|
629
|
use Moo; |
|
3
|
|
|
|
|
8
|
|
|
3
|
|
|
|
|
21
|
|
5
|
3
|
|
|
3
|
|
1427
|
use Catmandu::MARC; |
|
3
|
|
|
|
|
10
|
|
|
3
|
|
|
|
|
119
|
|
6
|
3
|
|
|
3
|
|
360
|
use Catmandu::Fix::Has; |
|
3
|
|
|
|
|
1143
|
|
|
3
|
|
|
|
|
27
|
|
7
|
3
|
|
|
3
|
|
2322
|
use Clone qw(clone); |
|
3
|
|
|
|
|
8
|
|
|
3
|
|
|
|
|
907
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
with 'Catmandu::Fix::Inlineable'; |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
our $VERSION = '1.19'; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
has path => (fix_arg => 1); |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
# Transform a raw MARC array into MARCXML |
16
|
|
|
|
|
|
|
sub fix { |
17
|
11
|
|
|
11
|
0
|
1998
|
my ($self, $data) = @_; |
18
|
11
|
|
|
|
|
40
|
my $path = $self->{path}; |
19
|
|
|
|
|
|
|
|
20
|
11
|
50
|
|
|
|
33
|
return $data unless exists $data->{$path}; |
21
|
|
|
|
|
|
|
|
22
|
11
|
50
|
|
|
|
34
|
if ($path eq 'record') { |
|
|
0
|
|
|
|
|
|
23
|
11
|
|
|
|
|
104
|
my $xml = Catmandu::MARC->instance->marc_xml($data); |
24
|
11
|
|
|
|
|
200
|
$data->{$path} = $xml; |
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
elsif (exists $data->{record}) { |
27
|
0
|
|
|
|
|
0
|
my $copy = clone($data->{record}); |
28
|
0
|
|
|
|
|
0
|
$data->{record} = $data->{$path}; |
29
|
0
|
|
|
|
|
0
|
my $xml = Catmandu::MARC->instance->marc_xml($data); |
30
|
0
|
|
|
|
|
0
|
$data->{$path} = $xml; |
31
|
0
|
|
|
|
|
0
|
$data->{record} = $copy; |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
else { |
34
|
0
|
|
|
|
|
0
|
$data->{record} = $data->{$path}; |
35
|
0
|
|
|
|
|
0
|
my $xml = Catmandu::MARC->instance->marc_xml($data); |
36
|
0
|
|
|
|
|
0
|
$data->{$path} = $xml; |
37
|
0
|
|
|
|
|
0
|
delete $data->{record}; |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
11
|
|
|
|
|
268
|
$data; |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
=head1 NAME |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
Catmandu::Fix::marc_xml - transform a Catmandu MARC record into MARCXML |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
=head1 SYNOPSIS |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
# Transforms the 'record' key into a MARCXML string |
50
|
|
|
|
|
|
|
marc_xml('record') |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
=head1 DESCRIPTION |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
Convert MARC data into a MARCXML string |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
=head1 METHODS |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
=head2 marc_xml(PATH) |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
Transform the MARC record found at PATH to MARC XML. |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
=head1 INLINE |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
This Fix can be used inline in a Perl script: |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
use Catmandu::Fix::marc_xml as => 'marc_xml'; |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
my $data = { record => [...] }; |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
$data = marc_xml($data); |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
=head1 SEE ALSO |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
L<Catmandu::Fix> |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
=cut |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
1; |