line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package MARC::Moose::Parser::MarcxmlSaxHandler; |
2
|
|
|
|
|
|
|
# ABSTRACT: SAX handler for parsing MARXML records |
3
|
|
|
|
|
|
|
$MARC::Moose::Parser::MarcxmlSaxHandler::VERSION = '1.0.44'; |
4
|
4
|
|
|
4
|
|
28
|
use strict; |
|
4
|
|
|
|
|
10
|
|
|
4
|
|
|
|
|
124
|
|
5
|
4
|
|
|
4
|
|
21
|
use warnings; |
|
4
|
|
|
|
|
7
|
|
|
4
|
|
|
|
|
136
|
|
6
|
|
|
|
|
|
|
|
7
|
4
|
|
|
4
|
|
1967
|
use XML::SAX; |
|
4
|
|
|
|
|
17082
|
|
|
4
|
|
|
|
|
219
|
|
8
|
4
|
|
|
4
|
|
38
|
use base qw( XML::SAX::Base ); |
|
4
|
|
|
|
|
9
|
|
|
4
|
|
|
|
|
4365
|
|
9
|
|
|
|
|
|
|
|
10
|
4
|
|
|
4
|
|
71594
|
use MARC::Moose::Field::Control; |
|
4
|
|
|
|
|
13
|
|
|
4
|
|
|
|
|
105
|
|
11
|
4
|
|
|
4
|
|
22
|
use MARC::Moose::Field::Std; |
|
4
|
|
|
|
|
10
|
|
|
4
|
|
|
|
|
1676
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
sub new { |
15
|
5
|
|
|
5
|
0
|
16
|
my $class = shift; |
16
|
5
|
|
33
|
|
|
43
|
return bless {}, ref($class) || $class; |
17
|
|
|
|
|
|
|
} |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
sub start_element { |
20
|
206
|
|
|
206
|
1
|
3404
|
my ($self, $element) = @_; |
21
|
206
|
|
|
|
|
313
|
my $name = $element->{Name}; |
22
|
206
|
|
|
|
|
344
|
$self->{data} = ''; |
23
|
206
|
100
|
|
|
|
671
|
if ( $name eq 'record' ) { |
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
24
|
4
|
|
|
|
|
156
|
$self->{record} = MARC::Moose::Record->new(); |
25
|
4
|
|
|
|
|
64
|
$self->{fields} = []; |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
elsif ( $name eq 'controlfield' ) { |
28
|
|
|
|
|
|
|
$self->{field} = MARC::Moose::Field::Control->new( |
29
|
0
|
|
|
|
|
0
|
tag => $element->{Attributes}{'{}tag'}{Value} ); |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
elsif ( $name eq 'datafield' ) { |
32
|
61
|
|
|
|
|
100
|
my $attr = $element->{Attributes}; |
33
|
61
|
|
|
|
|
97
|
my $ind1 = $attr->{'{}ind1'}{Value}; |
34
|
61
|
50
|
|
|
|
127
|
$ind1 = ' ' unless defined($ind1); |
35
|
61
|
|
|
|
|
102
|
my $ind2 = $attr->{'{}ind2'}{Value}; |
36
|
61
|
50
|
|
|
|
120
|
$ind2 = ' ' unless defined($ind2); |
37
|
|
|
|
|
|
|
$self->{field} = MARC::Moose::Field::Std->new( |
38
|
|
|
|
|
|
|
tag => $attr->{'{}tag'}{Value}, |
39
|
61
|
|
|
|
|
2100
|
ind1 => $ind1, |
40
|
|
|
|
|
|
|
ind2 => $ind2, |
41
|
|
|
|
|
|
|
); |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
elsif ( $name eq 'subfield' ) { |
44
|
|
|
|
|
|
|
$self->{code} = $element->{Attributes}{'{}code'}{Value} |
45
|
137
|
|
|
|
|
1053
|
} |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
sub end_element { |
50
|
206
|
|
|
206
|
1
|
1505
|
my ($self, $element) = @_; |
51
|
206
|
|
|
|
|
332
|
my $name = $element->{Name}; |
52
|
|
|
|
|
|
|
|
53
|
206
|
100
|
|
|
|
596
|
if ( $name eq 'leader' ) { |
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
54
|
4
|
|
|
|
|
10
|
my $record = $self->{record}; |
55
|
4
|
|
|
|
|
157
|
$record->_leader( $self->{data} ); |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
elsif ( $name eq 'controlfield' ) { |
58
|
0
|
|
|
|
|
0
|
my $field = $self->{field}; |
59
|
0
|
|
|
|
|
0
|
$field->value( $self->{data} ); |
60
|
0
|
|
|
|
|
0
|
push @{$self->{fields}}, $field; |
|
0
|
|
|
|
|
0
|
|
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
elsif ( $name eq 'datafield' ) { |
63
|
61
|
|
|
|
|
112
|
push @{$self->{fields}}, $self->{field}; |
|
61
|
|
|
|
|
357
|
|
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
elsif ( $name eq 'subfield' ) { |
66
|
137
|
|
|
|
|
205
|
my $field = $self->{field}; |
67
|
137
|
|
|
|
|
184
|
push @{$field->{subf}}, [ $self->{code}, $self->{data} ]; |
|
137
|
|
|
|
|
1035
|
|
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
elsif ( $name eq 'record' ) { |
70
|
4
|
|
|
|
|
15
|
my $record = $self->{record}; |
71
|
4
|
|
|
|
|
162
|
$record->fields( $self->{fields} ); |
72
|
|
|
|
|
|
|
} |
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
sub characters { |
77
|
441
|
|
|
441
|
1
|
3452
|
my ($self, $characters) = @_; |
78
|
441
|
|
|
|
|
3935
|
$self->{data} .= $characters->{Data}; |
79
|
|
|
|
|
|
|
} |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
1; |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
__END__ |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
=pod |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
=encoding UTF-8 |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
=head1 NAME |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
MARC::Moose::Parser::MarcxmlSaxHandler - SAX handler for parsing MARXML records |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
=head1 VERSION |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
version 1.0.44 |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
=head1 AUTHOR |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
Frédéric Demians <f.demians@tamil.fr> |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
This software is copyright (c) 2021 by Frédéric Demians. |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
106
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
=cut |