| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package MARC::Detrans::Config; |
|
2
|
|
|
|
|
|
|
|
|
3
|
7
|
|
|
7
|
|
28406
|
use strict; |
|
|
7
|
|
|
|
|
15
|
|
|
|
7
|
|
|
|
|
219
|
|
|
4
|
7
|
|
|
7
|
|
35
|
use warnings; |
|
|
7
|
|
|
|
|
13
|
|
|
|
7
|
|
|
|
|
307
|
|
|
5
|
7
|
|
|
7
|
|
56
|
use base qw( Class::Accessor ); |
|
|
7
|
|
|
|
|
11
|
|
|
|
7
|
|
|
|
|
7980
|
|
|
6
|
7
|
|
|
7
|
|
26332
|
use XML::SAX::ParserFactory; |
|
|
7
|
|
|
|
|
65582
|
|
|
|
7
|
|
|
|
|
250
|
|
|
7
|
7
|
|
|
7
|
|
63
|
use Carp qw( croak ); |
|
|
7
|
|
|
|
|
150
|
|
|
|
7
|
|
|
|
|
4083
|
|
|
8
|
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
=head1 NAME |
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
MARC::Detrans::Config - Stores de-transliteration configuration data |
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
use MARC::Detrans::Config; |
|
16
|
|
|
|
|
|
|
my $config = MARC::Detrans::Config->new( 'file.xml' ); |
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
19
|
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
MARC::Detrans::Config will read detransliteration rules from an XML file which |
|
21
|
|
|
|
|
|
|
you can then use to create a MARC::Detrans::Converter object to actually convert |
|
22
|
|
|
|
|
|
|
MARC records. |
|
23
|
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
b |
|
48
|
|
|
|
|
|
|
B |
|
49
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
$aNicholas $bI, $cEmperor of Russia, $d1796-1855 |
|
56
|
|
|
|
|
|
|
$a^ESC(NnIKOLAJ^ESCs, $bI, $c^ESC(NiMPERATOR^ESCs ^ESC(NwSEROSSIJSKIJ^ESCs, $d1796-1855 |
|
57
|
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
=head1 METHODS |
|
62
|
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
=head2 new() |
|
64
|
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
The constructor, which you should pass the file path for the XML configuration. |
|
66
|
|
|
|
|
|
|
If you want to configure the MARC::Detrans::Config object manually you |
|
67
|
|
|
|
|
|
|
can not pass in a path, but you ordinarily wouldn't want to do this. |
|
68
|
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
=cut |
|
70
|
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
sub new { |
|
72
|
7
|
|
|
7
|
1
|
775
|
my ( $class, $file ) = @_; |
|
73
|
7
|
50
|
66
|
|
|
134
|
croak( "config file doesn't exist" ) if $file and ! -f $file; |
|
74
|
7
|
|
33
|
|
|
55
|
my $self = bless { file => $file }, $class || $class; |
|
75
|
7
|
|
|
|
|
38
|
$self->_parse( $file ); |
|
76
|
7
|
|
|
|
|
45
|
return( $self ); |
|
77
|
|
|
|
|
|
|
} |
|
78
|
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
=head2 rules() |
|
80
|
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
Returns a MARC::Detrans::Rules object that contains the transliteration |
|
82
|
|
|
|
|
|
|
rules being used in the configuration. |
|
83
|
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
=head2 names() |
|
85
|
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
Returns a MARC::Detrans::Names object that contains the authority mappings |
|
87
|
|
|
|
|
|
|
being used in the configuration. |
|
88
|
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
=head2 allEscapeCodes() |
|
90
|
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
Returns a list of all the MARC8 escape codes that are in use in this |
|
92
|
|
|
|
|
|
|
configuration. Useful for when you are building 006 fields that itemize |
|
93
|
|
|
|
|
|
|
the different character set codes in use. |
|
94
|
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
=cut |
|
96
|
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
sub allEscapeCodes { |
|
98
|
21
|
|
|
21
|
1
|
34
|
return @{ shift->{allEscapeCodes} }; |
|
|
21
|
|
|
|
|
125
|
|
|
99
|
|
|
|
|
|
|
} |
|
100
|
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
=head2 detransFields() |
|
102
|
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
Returns a list of fields that the configuration lists as desiring |
|
104
|
|
|
|
|
|
|
de-transliteration. If you need to you can pass in an array of |
|
105
|
|
|
|
|
|
|
field names you'd like to detransliterate...but normally you won't |
|
106
|
|
|
|
|
|
|
want to do this since the value come from the XML configuration. |
|
107
|
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
=cut |
|
109
|
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
sub detransFields { |
|
111
|
26
|
|
|
26
|
1
|
1435
|
my ($self,@fields) = @_; |
|
112
|
26
|
100
|
|
|
|
86
|
if ( @fields ) { $self->{lookForFields} = \@fields; } |
|
|
2
|
|
|
|
|
6
|
|
|
113
|
26
|
|
|
|
|
40
|
return @{ $self->{lookForFields} }; |
|
|
26
|
|
|
|
|
139
|
|
|
114
|
|
|
|
|
|
|
} |
|
115
|
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
=head2 needsDetrans() |
|
117
|
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
Returns true (1) or false (undef) to indicate whether the config lists |
|
119
|
|
|
|
|
|
|
a particular field/subfield combination as needing detransliteration. |
|
120
|
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
=cut |
|
122
|
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
sub needsDetrans { |
|
124
|
41
|
|
|
41
|
1
|
187
|
my ( $self, %args ) = @_; |
|
125
|
41
|
50
|
33
|
|
|
482
|
croak( "must supply field and subfield parameters" ) |
|
126
|
|
|
|
|
|
|
if ! exists $args{field} or ! exists $args{subfield}; |
|
127
|
41
|
100
|
|
|
|
360
|
return 1 if $self->{detransFields}{$args{field}.$args{subfield}}; |
|
128
|
5
|
|
|
|
|
43
|
return; |
|
129
|
|
|
|
|
|
|
} |
|
130
|
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
=head2 needsCopy() |
|
132
|
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
Returns true (1) or false (undef) to indicate wheter the config lists |
|
134
|
|
|
|
|
|
|
a particular field/subfield combination as needing a copy. |
|
135
|
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
=cut |
|
137
|
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
sub needsCopy { |
|
139
|
6
|
|
|
6
|
1
|
26
|
my ( $self, %args ) = @_; |
|
140
|
6
|
50
|
33
|
|
|
43
|
croak( "must supply field and subfield parameters" ) |
|
141
|
|
|
|
|
|
|
if ! exists $args{field} or ! exists $args{subfield}; |
|
142
|
6
|
100
|
|
|
|
47
|
return 1 if $self->{copyFields}{$args{field}.$args{subfield}}; |
|
143
|
1
|
|
|
|
|
5
|
return; |
|
144
|
|
|
|
|
|
|
} |
|
145
|
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
=head1 AUTHORS |
|
147
|
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
=over 4 |
|
149
|
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
=item * Ed Summers |
|
151
|
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
=cut |
|
153
|
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
MARC::Detrans::Config->mk_accessors( qw( |
|
155
|
|
|
|
|
|
|
rules |
|
156
|
|
|
|
|
|
|
names |
|
157
|
|
|
|
|
|
|
languageName |
|
158
|
|
|
|
|
|
|
languageCode |
|
159
|
|
|
|
|
|
|
scriptName |
|
160
|
|
|
|
|
|
|
scriptCode |
|
161
|
|
|
|
|
|
|
scriptOrientation |
|
162
|
|
|
|
|
|
|
) ); |
|
163
|
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
sub _parse { |
|
165
|
7
|
|
|
7
|
|
17
|
my $self = shift; |
|
166
|
7
|
|
|
|
|
46
|
my $handler = ConfigHandler->new(); |
|
167
|
7
|
|
|
|
|
66
|
my $parser = XML::SAX::ParserFactory->parser( Handler => $handler ); |
|
168
|
|
|
|
|
|
|
## we skip parsing if we don't have a file to parse, which |
|
169
|
|
|
|
|
|
|
## can happen when the configuration is being manually configured |
|
170
|
|
|
|
|
|
|
## in tests... |
|
171
|
7
|
100
|
|
|
|
692305
|
$parser->parse_uri( $self->{ file } ) if $self->{ file }; |
|
172
|
7
|
|
|
|
|
1584
|
$self->rules( $handler->rules() ); |
|
173
|
7
|
|
|
|
|
150
|
$self->names( $handler->names() ); |
|
174
|
7
|
|
|
|
|
201
|
$self->languageName( $handler->languageName() ); |
|
175
|
7
|
|
|
|
|
84
|
$self->languageCode( $handler->languageCode() ); |
|
176
|
7
|
|
|
|
|
81
|
$self->scriptName( $handler->scriptName() ); |
|
177
|
7
|
|
|
|
|
76
|
$self->scriptCode( $handler->scriptCode() ); |
|
178
|
7
|
|
|
|
|
81
|
$self->scriptOrientation( $handler->scriptOrientation() ); |
|
179
|
7
|
|
|
|
|
80
|
$self->{lookForFields} = $handler->{lookForFields}; |
|
180
|
7
|
|
|
|
|
23
|
$self->{detransFields} = $handler->{detransFields}; |
|
181
|
7
|
|
|
|
|
21
|
$self->{copyFields} = $handler->{copyFields}; |
|
182
|
7
|
|
|
|
|
15
|
$self->{allEscapeCodes} = [ sort keys %{ $handler->{allEscapeCodes} } ]; |
|
|
7
|
|
|
|
|
389
|
|
|
183
|
|
|
|
|
|
|
} |
|
184
|
|
|
|
|
|
|
|
|
185
|
|
|
|
|
|
|
|
|
186
|
|
|
|
|
|
|
## the SAX handler for the config file |
|
187
|
|
|
|
|
|
|
|
|
188
|
|
|
|
|
|
|
package ConfigHandler; |
|
189
|
|
|
|
|
|
|
|
|
190
|
7
|
|
|
7
|
|
497
|
use base qw( XML::SAX::Base ); |
|
|
7
|
|
|
|
|
11
|
|
|
|
7
|
|
|
|
|
11777
|
|
|
191
|
7
|
|
|
7
|
|
239167
|
use MARC::Detrans::Rules; |
|
|
7
|
|
|
|
|
23
|
|
|
|
7
|
|
|
|
|
301
|
|
|
192
|
7
|
|
|
7
|
|
4800
|
use MARC::Detrans::Rule; |
|
|
7
|
|
|
|
|
25
|
|
|
|
7
|
|
|
|
|
223
|
|
|
193
|
7
|
|
|
7
|
|
5172
|
use MARC::Detrans::Names; |
|
|
7
|
|
|
|
|
19
|
|
|
|
7
|
|
|
|
|
201
|
|
|
194
|
7
|
|
|
7
|
|
4619
|
use MARC::Detrans::Name; |
|
|
7
|
|
|
|
|
18
|
|
|
|
7
|
|
|
|
|
51
|
|
|
195
|
|
|
|
|
|
|
|
|
196
|
|
|
|
|
|
|
sub new { |
|
197
|
7
|
|
|
7
|
|
18
|
my $class = shift; |
|
198
|
7
|
|
|
|
|
98
|
my $self = $class->SUPER::new(); |
|
199
|
7
|
|
|
|
|
734
|
$self->resetFlags(); |
|
200
|
7
|
|
|
|
|
55
|
$self->{rules} = MARC::Detrans::Rules->new(); |
|
201
|
7
|
|
|
|
|
60
|
$self->{names} = MARC::Detrans::Names->new(); |
|
202
|
7
|
|
|
|
|
33
|
$self->{lookForFields} = []; |
|
203
|
7
|
|
|
|
|
28
|
$self->{detransFields} = {}; |
|
204
|
7
|
|
|
|
|
21
|
$self->{copyFields} = {}; |
|
205
|
7
|
|
|
|
|
23
|
$self->{allEscapeCodes} = {}; |
|
206
|
7
|
|
33
|
|
|
62
|
return bless $self, $class || ref($class); |
|
207
|
|
|
|
|
|
|
} |
|
208
|
|
|
|
|
|
|
|
|
209
|
7
|
|
|
7
|
|
152
|
sub rules { return shift->{rules}; } |
|
210
|
7
|
|
|
7
|
|
42
|
sub names { return shift->{names}; } |
|
211
|
7
|
|
|
7
|
|
47
|
sub languageName { return shift->{languageName}; } |
|
212
|
7
|
|
|
7
|
|
293
|
sub languageCode { return shift->{languageCode}; } |
|
213
|
7
|
|
|
7
|
|
43
|
sub scriptName { return shift->{scriptName}; } |
|
214
|
7
|
|
|
7
|
|
43
|
sub scriptCode { return shift->{scriptCode}; } |
|
215
|
7
|
|
|
7
|
|
44
|
sub scriptOrientation { return shift->{scriptOrientation}; } |
|
216
|
|
|
|
|
|
|
|
|
217
|
|
|
|
|
|
|
sub start_element { |
|
218
|
1435
|
|
|
1435
|
|
890119
|
my ( $self, $data ) = @_; |
|
219
|
1435
|
|
|
|
|
2919
|
my $tag = $data->{Name}; |
|
220
|
|
|
|
|
|
|
## start of rule |
|
221
|
1435
|
100
|
|
|
|
12754
|
if ( $tag eq 'rule' ) { |
|
|
|
100
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
222
|
453
|
|
|
|
|
1138
|
$self->resetFlags(); |
|
223
|
453
|
|
|
|
|
1268
|
$self->{currentPosition} = $data->{Attributes}{'{}position'}{Value}; |
|
224
|
453
|
|
|
|
|
1457
|
$self->{insideRule} = 1;; |
|
225
|
|
|
|
|
|
|
} |
|
226
|
|
|
|
|
|
|
## start of name |
|
227
|
|
|
|
|
|
|
elsif ( $tag eq 'name' ) { |
|
228
|
4
|
|
|
|
|
164
|
$self->resetFlags(); |
|
229
|
4
|
|
|
|
|
14
|
$self->{insideName} = 1; |
|
230
|
|
|
|
|
|
|
} |
|
231
|
|
|
|
|
|
|
## start of roman |
|
232
|
|
|
|
|
|
|
elsif ( $tag eq 'roman' ) { |
|
233
|
457
|
|
|
|
|
1964
|
$self->{insideRoman} = 1; |
|
234
|
|
|
|
|
|
|
} |
|
235
|
|
|
|
|
|
|
## start of marc |
|
236
|
|
|
|
|
|
|
elsif ( $tag eq 'marc' ) { |
|
237
|
457
|
|
|
|
|
881
|
$self->{insideMarc} = 1; |
|
238
|
457
|
|
|
|
|
1576
|
$self->{currentEscape} = $data->{Attributes}{'{}escape'}{Value}; |
|
239
|
|
|
|
|
|
|
## keep track of all escape codes used |
|
240
|
457
|
100
|
|
|
|
3381
|
$self->{allEscapeCodes}{ $self->{currentEscape} }++ |
|
241
|
|
|
|
|
|
|
if $self->{currentEscape}; |
|
242
|
|
|
|
|
|
|
} |
|
243
|
|
|
|
|
|
|
## language name/code |
|
244
|
|
|
|
|
|
|
elsif ( $tag eq 'language' ) { |
|
245
|
5
|
|
|
|
|
26
|
$self->{languageName} = $data->{Attributes}{'{}name'}{Value}; |
|
246
|
5
|
|
|
|
|
32
|
$self->{languageCode} = $data->{Attributes}{'{}code'}{Value}; |
|
247
|
|
|
|
|
|
|
} |
|
248
|
|
|
|
|
|
|
## script name/code |
|
249
|
|
|
|
|
|
|
elsif ( $tag eq 'script' ) { |
|
250
|
4
|
|
|
|
|
23
|
$self->{scriptName} = $data->{Attributes}{'{}name'}{Value}; |
|
251
|
4
|
|
|
|
|
20
|
$self->{scriptCode} = $data->{Attributes}{'{}code'}{Value}; |
|
252
|
4
|
|
|
|
|
201
|
$self->{scriptOrientation}=$data->{Attributes}{'{}orientation'}{Value}; |
|
253
|
|
|
|
|
|
|
} |
|
254
|
|
|
|
|
|
|
## start of fields to detransliterate |
|
255
|
|
|
|
|
|
|
elsif ( $tag eq 'detrans-fields' ) { |
|
256
|
9
|
|
|
|
|
40
|
$self->{insideDetransFields} = 1; |
|
257
|
|
|
|
|
|
|
} |
|
258
|
|
|
|
|
|
|
## start of fields to copy |
|
259
|
|
|
|
|
|
|
elsif ( $tag eq 'copy-fields' ) { |
|
260
|
0
|
|
|
|
|
0
|
$self->{insideCopyFields} = 1; |
|
261
|
|
|
|
|
|
|
} |
|
262
|
|
|
|
|
|
|
## start of field in either detrans-fields and copy-fields |
|
263
|
|
|
|
|
|
|
elsif ( $tag eq 'field' ) { |
|
264
|
9
|
|
|
|
|
32
|
my $field = $data->{Attributes}{'{}tag'}{Value}; |
|
265
|
9
|
|
|
|
|
31
|
$self->{field} = $field; |
|
266
|
9
|
|
|
|
|
46
|
push( @{ $self->{lookForFields} }, $field ) |
|
|
9
|
|
|
|
|
135
|
|
|
267
|
9
|
50
|
|
|
|
18
|
unless grep /$field/, @{$self->{lookForFields}}; |
|
268
|
|
|
|
|
|
|
} |
|
269
|
|
|
|
|
|
|
## start of subfield in field element |
|
270
|
|
|
|
|
|
|
elsif ( $tag eq 'subfield' ) { |
|
271
|
32
|
|
|
|
|
93
|
my $subfield = $data->{Attributes}{'{}code'}{Value}; |
|
272
|
32
|
|
|
|
|
72
|
my $field = $self->{field}; |
|
273
|
|
|
|
|
|
|
|
|
274
|
|
|
|
|
|
|
## figure out if this subfield needs copying or detransliterating |
|
275
|
32
|
|
|
|
|
46
|
my $copy = 0; |
|
276
|
32
|
100
|
66
|
|
|
188
|
if ( $data->{Attributes}{'{}copy'} |
|
277
|
|
|
|
|
|
|
and $data->{Attributes}{'{}copy'}{Value} eq 'true' ) { |
|
278
|
14
|
|
|
|
|
24
|
$copy = 1; |
|
279
|
|
|
|
|
|
|
} |
|
280
|
|
|
|
|
|
|
## add the field/subfield combo to appropriate hash |
|
281
|
|
|
|
|
|
|
## to use later to figure out if it needs detrans or copy |
|
282
|
32
|
100
|
|
|
|
80
|
if ( $copy ) { |
|
283
|
14
|
|
|
|
|
89
|
$self->{copyFields}{$field.$subfield} = 1; |
|
284
|
|
|
|
|
|
|
} else { |
|
285
|
18
|
|
|
|
|
114
|
$self->{detransFields}{$field.$subfield} = 1; |
|
286
|
|
|
|
|
|
|
} |
|
287
|
|
|
|
|
|
|
} |
|
288
|
|
|
|
|
|
|
} |
|
289
|
|
|
|
|
|
|
|
|
290
|
|
|
|
|
|
|
sub end_element { |
|
291
|
1435
|
|
|
1435
|
|
315015
|
my ( $self, $data ) = @_; |
|
292
|
1435
|
|
|
|
|
3029
|
my $tag = $data->{Name}; |
|
293
|
|
|
|
|
|
|
## end of rule, so build the rule and add it |
|
294
|
1435
|
100
|
|
|
|
6148
|
if ( $tag eq 'rule' ) { |
|
|
|
100
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
295
|
453
|
|
|
|
|
3113
|
my $rule = MARC::Detrans::Rule->new( |
|
296
|
|
|
|
|
|
|
from => $self->{romanText}, |
|
297
|
|
|
|
|
|
|
to => $self->{marcText}, |
|
298
|
|
|
|
|
|
|
escape => $self->{currentEscape}, |
|
299
|
|
|
|
|
|
|
position => $self->{currentPosition} |
|
300
|
|
|
|
|
|
|
); |
|
301
|
453
|
|
|
|
|
2129
|
$self->{rules}->addRule( $rule ); |
|
302
|
453
|
|
|
|
|
2981
|
$self->resetFlags(); |
|
303
|
|
|
|
|
|
|
} |
|
304
|
|
|
|
|
|
|
## end of name, so build the name and ad it |
|
305
|
|
|
|
|
|
|
elsif ( $tag eq 'name' ) { |
|
306
|
4
|
|
|
|
|
45
|
my $name = MARC::Detrans::Name->new( |
|
307
|
|
|
|
|
|
|
from => $self->{romanText}, |
|
308
|
|
|
|
|
|
|
to => $self->{marcText}, |
|
309
|
|
|
|
|
|
|
); |
|
310
|
4
|
|
|
|
|
73
|
$self->{names}->addName( $name ); |
|
311
|
4
|
|
|
|
|
16
|
$self->resetFlags(); |
|
312
|
|
|
|
|
|
|
} |
|
313
|
|
|
|
|
|
|
## end of marc section, store away the text |
|
314
|
|
|
|
|
|
|
elsif ( $tag eq 'marc' ) { |
|
315
|
457
|
|
|
|
|
1115
|
$self->{marcText} = $self->{currentText}; |
|
316
|
457
|
|
|
|
|
765
|
$self->{currentText} = ''; |
|
317
|
457
|
|
|
|
|
1464
|
$self->{insideMarc} = 0; |
|
318
|
|
|
|
|
|
|
} |
|
319
|
|
|
|
|
|
|
## end of roman section, store away the text |
|
320
|
|
|
|
|
|
|
elsif ( $tag eq 'roman' ) { |
|
321
|
457
|
|
|
|
|
925
|
$self->{romanText} = $self->{currentText}; |
|
322
|
457
|
|
|
|
|
705
|
$self->{currentText} = ''; |
|
323
|
457
|
|
|
|
|
1670
|
$self->{insideRoman} = 0; |
|
324
|
|
|
|
|
|
|
} |
|
325
|
|
|
|
|
|
|
## end of detrans-fields |
|
326
|
|
|
|
|
|
|
elsif ( $tag eq 'detrans-fields' ) { |
|
327
|
9
|
|
|
|
|
40
|
$self->{insideDetransFields} = 0; |
|
328
|
|
|
|
|
|
|
} |
|
329
|
|
|
|
|
|
|
## end of copy fields |
|
330
|
|
|
|
|
|
|
elsif ( $tag eq 'copy-fields' ) { |
|
331
|
0
|
|
|
|
|
0
|
$self->{insideCopyFields} = 0; |
|
332
|
|
|
|
|
|
|
} |
|
333
|
|
|
|
|
|
|
} |
|
334
|
|
|
|
|
|
|
|
|
335
|
|
|
|
|
|
|
sub characters { |
|
336
|
2812
|
|
|
2812
|
|
248270
|
my ( $self, $data ) = @_; |
|
337
|
|
|
|
|
|
|
## only store text if we're in a marc or roman tag |
|
338
|
2812
|
100
|
100
|
|
|
26423
|
if ( $self->{insideMarc} or $self->{insideRoman} |
|
|
|
|
66
|
|
|
|
|
|
339
|
|
|
|
|
|
|
or $self->{insideSubfield} ) { |
|
340
|
902
|
|
|
|
|
4489
|
$self->{currentText} .= $data->{Data}; |
|
341
|
|
|
|
|
|
|
} |
|
342
|
|
|
|
|
|
|
} |
|
343
|
|
|
|
|
|
|
|
|
344
|
|
|
|
|
|
|
sub resetFlags { |
|
345
|
921
|
|
|
921
|
|
1519
|
my $self = shift; |
|
346
|
921
|
|
|
|
|
1514
|
$self->{insideRule} = 0; |
|
347
|
921
|
|
|
|
|
1240
|
$self->{insideName} = 0; |
|
348
|
921
|
|
|
|
|
1240
|
$self->{insideRoman} = 0; |
|
349
|
921
|
|
|
|
|
2161
|
$self->{insideMarc} = 0; |
|
350
|
921
|
|
|
|
|
1185
|
$self->{insideDetransFields} = 0; |
|
351
|
921
|
|
|
|
|
1453
|
$self->{insideCopyFields} = 0; |
|
352
|
921
|
|
|
|
|
1229
|
$self->{currentText} = ''; |
|
353
|
921
|
|
|
|
|
1295
|
$self->{marcText} = ''; |
|
354
|
921
|
|
|
|
|
1340
|
$self->{romanText} = ''; |
|
355
|
921
|
|
|
|
|
1342
|
$self->{currentEscape} = ''; |
|
356
|
921
|
|
|
|
|
2725
|
$self->{field} = ''; |
|
357
|
|
|
|
|
|
|
} |
|
358
|
|
|
|
|
|
|
|
|
359
|
|
|
|
|
|
|
1; |