[Koha-patches] [PATCH] Bug 6799 rebuild_zebra.pl -x produces invalid XML records
Frédéric Demians
f.demians at tamil.fr
Sat Aug 27 13:33:50 CEST 2011
This patch allow to handle properly items containing extended characters and
send valid XML records to zebraidx
---
misc/migration_tools/rebuild_zebra.pl | 12 +++++-------
1 files changed, 5 insertions(+), 7 deletions(-)
diff --git a/misc/migration_tools/rebuild_zebra.pl b/misc/migration_tools/rebuild_zebra.pl
index dadf43f..7494656 100755
--- a/misc/migration_tools/rebuild_zebra.pl
+++ b/misc/migration_tools/rebuild_zebra.pl
@@ -323,19 +323,17 @@ sub export_marc_records_from_sth {
my @items = GetItemsInfo($record_number);
if (@items){
my $record = MARC::Record->new;
+ $record->encoding('UTF-8');
my @itemsrecord;
foreach my $item (@items){
my $record = Item2Marc($item, $record_number);
push @itemsrecord, $record->field($itemtag);
}
$record->insert_fields_ordered(@itemsrecord);
- my $itemsxml=$record->as_xml_record();
- my $searchstring = '<record>\n';
- my $index = index($itemsxml, '<record>\n', 0);
- $itemsxml = substr($itemsxml, $index + length($searchstring));
- $searchstring = '</record>';
- $marcxml = substr($marcxml, 0, index($marcxml, $searchstring));
- $marcxml .= $itemsxml;
+ my $itemsxml = $record->as_xml_record();
+ $marcxml =
+ substr($marcxml, 0, length($marcxml)-10) .
+ substr($itemsxml, index($itemsxml, "</leader>\n", 0) + 10);
}
}
if ( $marcxml ) {
--
1.7.5.1
More information about the Koha-patches
mailing list