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.45'; |
4
|
4
|
|
|
4
|
|
30
|
use strict; |
|
4
|
|
|
|
|
10
|
|
|
4
|
|
|
|
|
125
|
|
5
|
4
|
|
|
4
|
|
33
|
use warnings; |
|
4
|
|
|
|
|
9
|
|
|
4
|
|
|
|
|
127
|
|
6
|
|
|
|
|
|
|
|
7
|
4
|
|
|
4
|
|
3100
|
use XML::SAX; |
|
4
|
|
|
|
|
17844
|
|
|
4
|
|
|
|
|
215
|
|
8
|
4
|
|
|
4
|
|
40
|
use base qw( XML::SAX::Base ); |
|
4
|
|
|
|
|
14
|
|
|
4
|
|
|
|
|
4828
|
|
9
|
|
|
|
|
|
|
|
10
|
4
|
|
|
4
|
|
77633
|
use MARC::Moose::Field::Control; |
|
4
|
|
|
|
|
13
|
|
|
4
|
|
|
|
|
105
|
|
11
|
4
|
|
|
4
|
|
25
|
use MARC::Moose::Field::Std; |
|
4
|
|
|
|
|
10
|
|
|
4
|
|
|
|
|
1930
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
sub new { |
15
|
5
|
|
|
5
|
0
|
16
|
my $class = shift; |
16
|
5
|
|
33
|
|
|
48
|
return bless {}, ref($class) || $class; |
17
|
|
|
|
|
|
|
} |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
sub start_element { |
20
|
206
|
|
|
206
|
1
|
2940
|
my ($self, $element) = @_; |
21
|
206
|
|
|
|
|
328
|
my $name = $element->{Name}; |
22
|
206
|
|
|
|
|
329
|
$self->{data} = ''; |
23
|
206
|
100
|
|
|
|
677
|
if ( $name eq 'record' ) { |
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
24
|
4
|
|
|
|
|
144
|
$self->{record} = MARC::Moose::Record->new(); |
25
|
4
|
|
|
|
|
47
|
$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
|
|
|
|
|
98
|
my $attr = $element->{Attributes}; |
33
|
61
|
|
|
|
|
94
|
my $ind1 = $attr->{'{}ind1'}{Value}; |
34
|
61
|
50
|
|
|
|
128
|
$ind1 = ' ' unless defined($ind1); |
35
|
61
|
|
|
|
|
101
|
my $ind2 = $attr->{'{}ind2'}{Value}; |
36
|
61
|
50
|
|
|
|
133
|
$ind2 = ' ' unless defined($ind2); |
37
|
|
|
|
|
|
|
$self->{field} = MARC::Moose::Field::Std->new( |
38
|
|
|
|
|
|
|
tag => $attr->{'{}tag'}{Value}, |
39
|
61
|
|
|
|
|
1968
|
ind1 => $ind1, |
40
|
|
|
|
|
|
|
ind2 => $ind2, |
41
|
|
|
|
|
|
|
); |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
elsif ( $name eq 'subfield' ) { |
44
|
|
|
|
|
|
|
$self->{code} = $element->{Attributes}{'{}code'}{Value} |
45
|
137
|
|
|
|
|
1025
|
} |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
sub end_element { |
50
|
206
|
|
|
206
|
1
|
1506
|
my ($self, $element) = @_; |
51
|
206
|
|
|
|
|
302
|
my $name = $element->{Name}; |
52
|
|
|
|
|
|
|
|
53
|
206
|
100
|
|
|
|
587
|
if ( $name eq 'leader' ) { |
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
54
|
4
|
|
|
|
|
10
|
my $record = $self->{record}; |
55
|
4
|
|
|
|
|
126
|
$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
|
|
|
|
|
88
|
push @{$self->{fields}}, $self->{field}; |
|
61
|
|
|
|
|
422
|
|
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
elsif ( $name eq 'subfield' ) { |
66
|
137
|
|
|
|
|
218
|
my $field = $self->{field}; |
67
|
137
|
|
|
|
|
165
|
push @{$field->{subf}}, [ $self->{code}, $self->{data} ]; |
|
137
|
|
|
|
|
973
|
|
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
elsif ( $name eq 'record' ) { |
70
|
4
|
|
|
|
|
7
|
my $record = $self->{record}; |
71
|
4
|
|
|
|
|
119
|
$record->fields( $self->{fields} ); |
72
|
|
|
|
|
|
|
} |
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
sub characters { |
77
|
441
|
|
|
441
|
1
|
3238
|
my ($self, $characters) = @_; |
78
|
441
|
|
|
|
|
3746
|
$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.45 |
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) 2022 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 |