| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package MARC::Moose::Formater::Marcxml; |
|
2
|
|
|
|
|
|
|
#ABSTRACT: MARC::Moose record formater into MARCXML |
|
3
|
|
|
|
|
|
|
$MARC::Moose::Formater::Marcxml::VERSION = '1.0.46'; |
|
4
|
4
|
|
|
4
|
|
29
|
use Moose; |
|
|
4
|
|
|
|
|
10
|
|
|
|
4
|
|
|
|
|
24
|
|
|
5
|
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
extends 'MARC::Moose::Formater'; |
|
7
|
|
|
|
|
|
|
|
|
8
|
4
|
|
|
4
|
|
25831
|
use MARC::Moose::Field::Control; |
|
|
4
|
|
|
|
|
12
|
|
|
|
4
|
|
|
|
|
85
|
|
|
9
|
4
|
|
|
4
|
|
18
|
use MARC::Moose::Field::Std; |
|
|
4
|
|
|
|
|
9
|
|
|
|
4
|
|
|
|
|
133
|
|
|
10
|
4
|
|
|
4
|
|
2479
|
use XML::Writer; |
|
|
4
|
|
|
|
|
30126
|
|
|
|
4
|
|
|
|
|
1343
|
|
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
override 'begin' => sub { |
|
14
|
|
|
|
|
|
|
return "<collection>\n"; |
|
15
|
|
|
|
|
|
|
}; |
|
16
|
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
override 'end' => sub { |
|
19
|
|
|
|
|
|
|
return "</collection>\n"; |
|
20
|
|
|
|
|
|
|
}; |
|
21
|
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
override 'format' => sub { |
|
24
|
|
|
|
|
|
|
my ($self, $record) = @_; |
|
25
|
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
my $str = ''; |
|
27
|
|
|
|
|
|
|
my $w = XML::Writer->new( OUTPUT => \$str, DATA_MODE => 1, DATA_INDENT => 2 ); |
|
28
|
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
$w->startTag( 'record' ); |
|
30
|
|
|
|
|
|
|
$w->startTag( 'leader' ); |
|
31
|
|
|
|
|
|
|
$w->characters( $record->leader ); |
|
32
|
|
|
|
|
|
|
$w->endTag(); |
|
33
|
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
for my $field ( @{$record->fields} ) { |
|
35
|
|
|
|
|
|
|
if ( ref($field) eq 'MARC::Moose::Field::Control' ) { |
|
36
|
|
|
|
|
|
|
$w->startTag( "controlfield", tag => $field->tag ); |
|
37
|
|
|
|
|
|
|
$w->characters( $field->value ); |
|
38
|
|
|
|
|
|
|
$w->endTag(); |
|
39
|
|
|
|
|
|
|
} |
|
40
|
|
|
|
|
|
|
else { |
|
41
|
|
|
|
|
|
|
$w->startTag( |
|
42
|
|
|
|
|
|
|
"datafield", tag => $field->tag, ind1 => $field->ind1, |
|
43
|
|
|
|
|
|
|
ind2 => $field->ind2 ); |
|
44
|
|
|
|
|
|
|
for ( @{$field->subf} ) { |
|
45
|
|
|
|
|
|
|
my ($letter, $value) = @$_; |
|
46
|
|
|
|
|
|
|
$w->startTag( "subfield", code => $letter ); |
|
47
|
|
|
|
|
|
|
# FIXME: XML::Writer should escape 1B (ESC) character, but it doesn't |
|
48
|
|
|
|
|
|
|
$value =~ s/\x1B//g; |
|
49
|
|
|
|
|
|
|
$w->characters( $value ); |
|
50
|
|
|
|
|
|
|
$w->endTag(); |
|
51
|
|
|
|
|
|
|
} |
|
52
|
|
|
|
|
|
|
$w->endTag(); |
|
53
|
|
|
|
|
|
|
} |
|
54
|
|
|
|
|
|
|
} |
|
55
|
|
|
|
|
|
|
$w->endTag(); |
|
56
|
|
|
|
|
|
|
return $str . "\n"; |
|
57
|
|
|
|
|
|
|
}; |
|
58
|
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
|
60
|
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
1; |
|
62
|
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
__END__ |
|
64
|
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
=pod |
|
66
|
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
=encoding UTF-8 |
|
68
|
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
=head1 NAME |
|
70
|
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
MARC::Moose::Formater::Marcxml - MARC::Moose record formater into MARCXML |
|
72
|
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
=head1 VERSION |
|
74
|
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
version 1.0.46 |
|
76
|
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
=head1 AUTHOR |
|
78
|
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
Frédéric Demians <f.demians@tamil.fr> |
|
80
|
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
|
82
|
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
This software is copyright (c) 2022 by Frédéric Demians. |
|
84
|
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
|
86
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
|
87
|
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
=cut |