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.46'; |
4
|
4
|
|
|
4
|
|
29
|
use strict; |
|
4
|
|
|
|
|
11
|
|
|
4
|
|
|
|
|
123
|
|
5
|
4
|
|
|
4
|
|
22
|
use warnings; |
|
4
|
|
|
|
|
8
|
|
|
4
|
|
|
|
|
118
|
|
6
|
|
|
|
|
|
|
|
7
|
4
|
|
|
4
|
|
2598
|
use XML::SAX; |
|
4
|
|
|
|
|
16712
|
|
|
4
|
|
|
|
|
200
|
|
8
|
4
|
|
|
4
|
|
32
|
use base qw( XML::SAX::Base ); |
|
4
|
|
|
|
|
12
|
|
|
4
|
|
|
|
|
4305
|
|
9
|
|
|
|
|
|
|
|
10
|
4
|
|
|
4
|
|
76581
|
use MARC::Moose::Field::Control; |
|
4
|
|
|
|
|
9
|
|
|
4
|
|
|
|
|
94
|
|
11
|
4
|
|
|
4
|
|
25
|
use MARC::Moose::Field::Std; |
|
4
|
|
|
|
|
10
|
|
|
4
|
|
|
|
|
1803
|
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
sub new { |
15
|
5
|
|
|
5
|
0
|
15
|
my $class = shift; |
16
|
5
|
|
33
|
|
|
53
|
return bless {}, ref($class) || $class; |
17
|
|
|
|
|
|
|
} |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
sub start_element { |
20
|
206
|
|
|
206
|
1
|
2889
|
my ($self, $element) = @_; |
21
|
206
|
|
|
|
|
345
|
my $name = $element->{Name}; |
22
|
206
|
|
|
|
|
323
|
$self->{data} = ''; |
23
|
206
|
100
|
|
|
|
744
|
if ( $name eq 'record' ) { |
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
24
|
4
|
|
|
|
|
133
|
$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
|
|
|
|
|
96
|
my $attr = $element->{Attributes}; |
33
|
61
|
|
|
|
|
97
|
my $ind1 = $attr->{'{}ind1'}{Value}; |
34
|
61
|
50
|
|
|
|
138
|
$ind1 = ' ' unless defined($ind1); |
35
|
61
|
|
|
|
|
97
|
my $ind2 = $attr->{'{}ind2'}{Value}; |
36
|
61
|
50
|
|
|
|
125
|
$ind2 = ' ' unless defined($ind2); |
37
|
|
|
|
|
|
|
$self->{field} = MARC::Moose::Field::Std->new( |
38
|
|
|
|
|
|
|
tag => $attr->{'{}tag'}{Value}, |
39
|
61
|
|
|
|
|
1887
|
ind1 => $ind1, |
40
|
|
|
|
|
|
|
ind2 => $ind2, |
41
|
|
|
|
|
|
|
); |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
elsif ( $name eq 'subfield' ) { |
44
|
|
|
|
|
|
|
$self->{code} = $element->{Attributes}{'{}code'}{Value} |
45
|
137
|
|
|
|
|
1047
|
} |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
sub end_element { |
50
|
206
|
|
|
206
|
1
|
1586
|
my ($self, $element) = @_; |
51
|
206
|
|
|
|
|
326
|
my $name = $element->{Name}; |
52
|
|
|
|
|
|
|
|
53
|
206
|
100
|
|
|
|
580
|
if ( $name eq 'leader' ) { |
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
54
|
4
|
|
|
|
|
16
|
my $record = $self->{record}; |
55
|
4
|
|
|
|
|
136
|
$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
|
|
|
|
|
83
|
push @{$self->{fields}}, $self->{field}; |
|
61
|
|
|
|
|
378
|
|
64
|
|
|
|
|
|
|
} |
65
|
|
|
|
|
|
|
elsif ( $name eq 'subfield' ) { |
66
|
137
|
|
|
|
|
226
|
my $field = $self->{field}; |
67
|
137
|
|
|
|
|
185
|
push @{$field->{subf}}, [ $self->{code}, $self->{data} ]; |
|
137
|
|
|
|
|
997
|
|
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
elsif ( $name eq 'record' ) { |
70
|
4
|
|
|
|
|
9
|
my $record = $self->{record}; |
71
|
4
|
|
|
|
|
136
|
$record->fields( $self->{fields} ); |
72
|
|
|
|
|
|
|
} |
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
sub characters { |
77
|
441
|
|
|
441
|
1
|
3325
|
my ($self, $characters) = @_; |
78
|
441
|
|
|
|
|
3952
|
$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.46 |
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 |