line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Catmandu::Fix::marc_xml; |
2
|
|
|
|
|
|
|
|
3
|
3
|
|
|
3
|
|
96606
|
use Catmandu::Sane; |
|
3
|
|
|
|
|
126938
|
|
|
3
|
|
|
|
|
19
|
|
4
|
3
|
|
|
3
|
|
598
|
use Moo; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
14
|
|
5
|
3
|
|
|
3
|
|
1293
|
use Catmandu::MARC; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
78
|
|
6
|
3
|
|
|
3
|
|
248
|
use Catmandu::Fix::Has; |
|
3
|
|
|
|
|
782
|
|
|
3
|
|
|
|
|
20
|
|
7
|
3
|
|
|
3
|
|
1794
|
use Clone qw(clone); |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
725
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
with 'Catmandu::Fix::Inlineable'; |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
our $VERSION = '1.21'; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
has path => (fix_arg => 1); |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
# Transform a raw MARC array into MARCXML |
16
|
|
|
|
|
|
|
sub fix { |
17
|
11
|
|
|
11
|
0
|
1700
|
my ($self, $data) = @_; |
18
|
11
|
|
|
|
|
32
|
my $path = $self->{path}; |
19
|
|
|
|
|
|
|
|
20
|
11
|
50
|
|
|
|
33
|
return $data unless exists $data->{$path}; |
21
|
|
|
|
|
|
|
|
22
|
11
|
50
|
|
|
|
31
|
if ($path eq 'record') { |
|
|
0
|
|
|
|
|
|
23
|
11
|
|
|
|
|
86
|
my $xml = Catmandu::MARC->instance->marc_xml($data); |
24
|
11
|
|
|
|
|
189
|
$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
|
|
|
|
|
269
|
$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; |