Lines 9-14
use Modern::Perl;
Link Here
|
9 |
use MARC::File::USMARC; |
9 |
use MARC::File::USMARC; |
10 |
use MARC::File::XML; |
10 |
use MARC::File::XML; |
11 |
use MARC::Batch; |
11 |
use MARC::Batch; |
|
|
12 |
use MARC::Lint; |
12 |
use Encode; |
13 |
use Encode; |
13 |
|
14 |
|
14 |
use Koha::Script; |
15 |
use Koha::Script; |
Lines 75-80
my $framework = '';
Link Here
|
75 |
my $localcust; |
76 |
my $localcust; |
76 |
my $marc_mod_template = ''; |
77 |
my $marc_mod_template = ''; |
77 |
my $marc_mod_template_id = -1; |
78 |
my $marc_mod_template_id = -1; |
|
|
79 |
my $strict_mode; |
78 |
$| = 1; |
80 |
$| = 1; |
79 |
|
81 |
|
80 |
GetOptions( |
82 |
GetOptions( |
Lines 111-116
GetOptions(
Link Here
|
111 |
'framework=s' => \$framework, |
113 |
'framework=s' => \$framework, |
112 |
'custom:s' => \$localcust, |
114 |
'custom:s' => \$localcust, |
113 |
'marcmodtemplate:s' => \$marc_mod_template, |
115 |
'marcmodtemplate:s' => \$marc_mod_template, |
|
|
116 |
'st|strict' => \$strict_mode, |
114 |
); |
117 |
); |
115 |
|
118 |
|
116 |
$biblios ||= !$authorities; |
119 |
$biblios ||= !$authorities; |
Lines 314-319
my $record_number = 0;
Link Here
|
314 |
my $logger = Koha::Logger->get; |
317 |
my $logger = Koha::Logger->get; |
315 |
my $schema = Koha::Database->schema; |
318 |
my $schema = Koha::Database->schema; |
316 |
my $marc_records = []; |
319 |
my $marc_records = []; |
|
|
320 |
my $lint = MARC::Lint->new; |
317 |
RECORD: while () { |
321 |
RECORD: while () { |
318 |
my $record; |
322 |
my $record; |
319 |
$record_number++; |
323 |
$record_number++; |
Lines 333-338
RECORD: while () {
Link Here
|
333 |
} |
337 |
} |
334 |
if ($record) { |
338 |
if ($record) { |
335 |
|
339 |
|
|
|
340 |
if ($strict_mode) { |
341 |
my $xml = $record->as_xml_record(); |
342 |
eval { MARC::Record::new_from_xml( $xml, 'UTF-8', "MARC21" ); }; |
343 |
if ($@) { |
344 |
print "Record $record_number generated invalid xml:\n"; |
345 |
$lint->check_record($record); |
346 |
foreach my $warning ( $lint->warnings ) { |
347 |
print " " . $warning . "\n"; |
348 |
} |
349 |
print " Record skipped!"; |
350 |
next; |
351 |
} |
352 |
} |
336 |
# transcode the record to UTF8 if needed & applicable. |
353 |
# transcode the record to UTF8 if needed & applicable. |
337 |
if ( $record->encoding() eq 'MARC-8' and not $skip_marc8_conversion ) { |
354 |
if ( $record->encoding() eq 'MARC-8' and not $skip_marc8_conversion ) { |
338 |
my ( $guessed_charset, $charset_errors ); |
355 |
my ( $guessed_charset, $charset_errors ); |
339 |
- |
|
|