line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
=head1 NAME |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
Catmandu::Exporter::MARC::ISO - Exporter for MARC records to ISO |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
=head1 SYNOPSIS |
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
# From the command line |
8
|
|
|
|
|
|
|
$ catmandu convert MARC --type ISO to MARC --type XML < /foo/bar.mrc |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
# From Perl |
11
|
|
|
|
|
|
|
use Catmandu; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
my $importer = Catmandu->importer('MARC', file => "/foo/bar.mrc" , type => 'ISO'); |
14
|
|
|
|
|
|
|
my $exporter = Catmandu->exporter('MARC', file => "/foo/bar.xml", type => 'XML' ); |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
$exporter->add($importer); |
17
|
|
|
|
|
|
|
$exporter->commit; |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
=head1 CONFIGURATION |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
=over |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
=item file |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
Write output to a local file given by its path or file handle. Alternatively a |
26
|
|
|
|
|
|
|
scalar reference can be passed to write to a string and a code reference can be |
27
|
|
|
|
|
|
|
used to write to a callback function. |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
=item fh |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
Write the output to an L<IO::Handle>. If not specified, |
32
|
|
|
|
|
|
|
L<Catmandu::Util::io|Catmandu::Util/IO-functions> is used to create the output |
33
|
|
|
|
|
|
|
handle from the C<file> argument or by using STDOUT. |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
=item fix |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
An ARRAY of one or more fixes or file scripts to be applied to exported items. |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
=item encoding |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
Binmode of the output stream C<fh>. Set to "C<:utf8>" by default. |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
=back |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
=head1 METHODS |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
See L<Catmandu::Exporter>, L<Catmandu::Addable>, L<Catmandu::Fixable>, |
48
|
|
|
|
|
|
|
L<Catmandu::Counter>, and L<Catmandu::Logger> for a full list of methods. |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
=head1 SEE ALSO |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
L<Catmandu::Exporter> |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
=cut |
55
|
|
|
|
|
|
|
package Catmandu::Exporter::MARC::ISO; |
56
|
2
|
|
|
2
|
|
65416
|
use Catmandu::Sane; |
|
2
|
|
|
|
|
136920
|
|
|
2
|
|
|
|
|
19
|
|
57
|
2
|
|
|
2
|
|
519
|
use Catmandu::Util qw(xml_escape is_different :array :is); |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
716
|
|
58
|
2
|
|
|
2
|
|
16
|
use Moo; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
16
|
|
59
|
2
|
|
|
2
|
|
1282
|
use MARC::Record; |
|
2
|
|
|
|
|
5319
|
|
|
2
|
|
|
|
|
92
|
|
60
|
2
|
|
|
2
|
|
15
|
use MARC::Field; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
50
|
|
61
|
2
|
|
|
2
|
|
977
|
use MARC::File::USMARC; |
|
2
|
|
|
|
|
16401
|
|
|
2
|
|
|
|
|
524
|
|
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
our $VERSION = '1.19'; |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
with 'Catmandu::Exporter', 'Catmandu::Exporter::MARC::Base'; |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
has record => (is => 'ro' , default => sub { 'record'}); |
68
|
|
|
|
|
|
|
has record_format => (is => 'ro' , default => sub { 'raw'} ); |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
sub add { |
71
|
|
|
|
|
|
|
my ($self, $data) = @_; |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
if ($self->record_format eq 'MARC-in-JSON') { |
74
|
|
|
|
|
|
|
$data = $self->_json_to_raw($data); |
75
|
|
|
|
|
|
|
} |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
my $marc = $self->_raw_to_marc_record($data->{$self->record}); |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
$self->fh->print(MARC::File::USMARC::encode($marc)); |
80
|
|
|
|
|
|
|
} |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
sub commit { |
83
|
|
|
|
|
|
|
my ($self) = @_; |
84
|
|
|
|
|
|
|
$self->fh->flush; |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
1; |
87
|
|
|
|
|
|
|
} |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
1; |