Lines 11-16
use C4::Biblio;
Link Here
|
11 |
use C4::AuthoritiesMarc; |
11 |
use C4::AuthoritiesMarc; |
12 |
use C4::Items; |
12 |
use C4::Items; |
13 |
use Koha::RecordProcessor; |
13 |
use Koha::RecordProcessor; |
|
|
14 |
use XML::LibXML; |
14 |
|
15 |
|
15 |
# |
16 |
# |
16 |
# script that checks zebradir structure & create directories & mandatory files if needed |
17 |
# script that checks zebradir structure & create directories & mandatory files if needed |
Lines 140-145
if ($do_munge) {
Link Here
|
140 |
munge_config(); |
141 |
munge_config(); |
141 |
} |
142 |
} |
142 |
|
143 |
|
|
|
144 |
my $tester = XML::LibXML->new(); |
145 |
|
143 |
if ($authorities) { |
146 |
if ($authorities) { |
144 |
index_records('authority', $directory, $skip_export, $skip_index, $process_zebraqueue, $as_xml, $noxml, $nosanitize, $do_not_clear_zebraqueue, $verbose_logging, $zebraidx_log_opt, $authorityserverdir); |
147 |
index_records('authority', $directory, $skip_export, $skip_index, $process_zebraqueue, $as_xml, $noxml, $nosanitize, $do_not_clear_zebraqueue, $verbose_logging, $zebraidx_log_opt, $authorityserverdir); |
145 |
} else { |
148 |
} else { |
Lines 377-384
sub export_marc_records_from_sth {
Link Here
|
377 |
substr($itemsxml, index($itemsxml, "</leader>\n", 0) + 10); |
380 |
substr($itemsxml, index($itemsxml, "</leader>\n", 0) + 10); |
378 |
} |
381 |
} |
379 |
} |
382 |
} |
|
|
383 |
# extra test to ensure that result is valid XML; otherwise |
384 |
# Zebra won't parse it in DOM mode |
385 |
eval { |
386 |
my $doc = $tester->parse_string($marcxml); |
387 |
}; |
388 |
if ($@) { |
389 |
warn "Error exporting record $record_number ($record_type): $@\n"; |
390 |
next; |
391 |
} |
380 |
if ( $marcxml ) { |
392 |
if ( $marcxml ) { |
381 |
print {$fh} $marcxml if $marcxml; |
393 |
$marcxml =~ s!<\?xml version="1.0" encoding="UTF-8"\?>\n!!; |
|
|
394 |
print {$fh} $marcxml; |
382 |
$num_exported++; |
395 |
$num_exported++; |
383 |
} |
396 |
} |
384 |
next; |
397 |
next; |
Lines 389-394
sub export_marc_records_from_sth {
Link Here
|
389 |
my $rec; |
402 |
my $rec; |
390 |
if ($as_xml) { |
403 |
if ($as_xml) { |
391 |
$rec = $marc->as_xml_record(C4::Context->preference('marcflavour')); |
404 |
$rec = $marc->as_xml_record(C4::Context->preference('marcflavour')); |
|
|
405 |
eval { |
406 |
my $doc = $tester->parse_string($rec); |
407 |
}; |
408 |
if ($@) { |
409 |
die "invalid XML: $@"; |
410 |
} |
392 |
$rec =~ s!<\?xml version="1.0" encoding="UTF-8"\?>\n!!; |
411 |
$rec =~ s!<\?xml version="1.0" encoding="UTF-8"\?>\n!!; |
393 |
} else { |
412 |
} else { |
394 |
$rec = $marc->as_usmarc(); |
413 |
$rec = $marc->as_usmarc(); |
Lines 397-403
sub export_marc_records_from_sth {
Link Here
|
397 |
$num_exported++; |
416 |
$num_exported++; |
398 |
}; |
417 |
}; |
399 |
if ($@) { |
418 |
if ($@) { |
400 |
warn "Error exporting record $record_number ($record_type) ".($noxml ? "not XML" : "XML"); |
419 |
warn "Error exporting record $record_number ($record_type) ".($noxml ? "not XML" : "XML"); |
|
|
420 |
warn "... specific error is $@" if $verbose_logging; |
401 |
} |
421 |
} |
402 |
} |
422 |
} |
403 |
} |
423 |
} |
404 |
- |
|
|