line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Catmandu::Fix::marc_xml; |
2
|
|
|
|
|
|
|
|
3
|
3
|
|
|
3
|
|
81195
|
use Catmandu::Sane; |
|
3
|
|
|
|
|
126104
|
|
|
3
|
|
|
|
|
23
|
|
4
|
3
|
|
|
3
|
|
730
|
use Moo; |
|
3
|
|
|
|
|
7
|
|
|
3
|
|
|
|
|
16
|
|
5
|
3
|
|
|
3
|
|
1388
|
use Catmandu::MARC; |
|
3
|
|
|
|
|
7
|
|
|
3
|
|
|
|
|
81
|
|
6
|
3
|
|
|
3
|
|
255
|
use Catmandu::Fix::Has; |
|
3
|
|
|
|
|
763
|
|
|
3
|
|
|
|
|
22
|
|
7
|
3
|
|
|
3
|
|
2050
|
use Clone qw(clone); |
|
3
|
|
|
|
|
7
|
|
|
3
|
|
|
|
|
867
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
with 'Catmandu::Fix::Inlineable'; |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
our $VERSION = '1.20'; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
has path => (fix_arg => 1); |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
# Transform a raw MARC array into MARCXML |
16
|
|
|
|
|
|
|
sub fix { |
17
|
11
|
|
|
11
|
0
|
2170
|
my ($self, $data) = @_; |
18
|
11
|
|
|
|
|
41
|
my $path = $self->{path}; |
19
|
|
|
|
|
|
|
|
20
|
11
|
50
|
|
|
|
47
|
return $data unless exists $data->{$path}; |
21
|
|
|
|
|
|
|
|
22
|
11
|
50
|
|
|
|
45
|
if ($path eq 'record') { |
|
|
0
|
|
|
|
|
|
23
|
11
|
|
|
|
|
155
|
my $xml = Catmandu::MARC->instance->marc_xml($data); |
24
|
11
|
|
|
|
|
286
|
$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
|
|
|
|
|
501
|
$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; |