bugfix for Biblio.pm based on feedback from production system. previous
version was dropping subfields in cases where the previous tag in the editor contained values (but only when multiple subfields existed in both tags). This version will be tested again in production environment to ensure it is actually fixed.
This commit is contained in:
parent
1b7da4dd9b
commit
90e93e3a4d
83
C4/Biblio.pm
83
C4/Biblio.pm
|
|
@ -1040,60 +1040,61 @@ sub MARChtml2xml {
|
|||
my ($tags,$subfields,$values,$indicator,$ind_tag) = @_;
|
||||
use MARC::File::XML;
|
||||
my $xml= MARC::File::XML::header();
|
||||
my $prevvalue;
|
||||
my $prevtag=-1;
|
||||
my $first=1;
|
||||
my $prevvalue;
|
||||
my $prevtag=-1;
|
||||
my $first=1;
|
||||
my $j = -1;
|
||||
for (my $i=0;$i<=@$tags;$i++){
|
||||
for (my $i=0;$i<=@$tags;$i++){
|
||||
if ((@$tags[$i] ne $prevtag)){
|
||||
$j++ unless (@$tags[$i] eq "");
|
||||
# deal with &, <, >,", ' that are not valid in a XML file.
|
||||
@$values[$i] =~ s/&/&/g;
|
||||
@$values[$i] =~ s/</</g;
|
||||
@$values[$i] =~ s/>/>/g;
|
||||
@$values[$i] =~ s/"/"/g;
|
||||
@$values[$i] =~ s/'/'/g;
|
||||
#warn "IND:".substr(@$indicator[$j],0,1).substr(@$indicator[$j],1,1)." ".@$tags[$i];
|
||||
if (!$first){
|
||||
$xml.="</datafield>\n";
|
||||
$first=1;
|
||||
$xml.="</datafield>\n";
|
||||
if (@$tags[$i] > 10) {
|
||||
my $ind1 = substr(@$indicator[$j],0,1);
|
||||
my $ind2 = substr(@$indicator[$j],1,1);
|
||||
$xml.="<datafield tag=\"@$tags[$i]\" ind1=\"$ind1\" ind2=\"$ind2\">\n";
|
||||
$xml.="<subfield code=\"@$subfields[$i]\">@$values[$i]</subfield>\n";
|
||||
$first=0;
|
||||
} else {
|
||||
$first=1;
|
||||
}
|
||||
else {
|
||||
if (@$values[$i] ne "") {
|
||||
# leader
|
||||
if (@$tags[$i] eq "000") {
|
||||
} else {
|
||||
if (@$values[$i] ne "") {
|
||||
# leader
|
||||
if (@$tags[$i] eq "000") {
|
||||
$xml.="<leader>@$values[$i]</leader>\n";
|
||||
$first=1;
|
||||
# rest of the fixed fields
|
||||
} elsif (@$tags[$i] < 10) {
|
||||
# rest of the fixed fields
|
||||
} elsif (@$tags[$i] < 10) {
|
||||
$xml.="<controlfield tag=\"@$tags[$i]\">@$values[$i]</controlfield>\n";
|
||||
$first=1;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
my $ind1 = substr(@$indicator[$j],0,1);
|
||||
my $ind2 = substr(@$indicator[$j],1,1);
|
||||
$xml.="<datafield tag=\"@$tags[$i]\" ind1=\"$ind1\" ind2=\"$ind2\">\n";
|
||||
$xml.="<subfield code=\"@$subfields[$i]\">@$values[$i]</subfield>\n";
|
||||
$first=0;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else { # @$tags[$i] eq $prevtag
|
||||
if (@$values[$i] eq "") {
|
||||
}
|
||||
else {
|
||||
if ($first){
|
||||
my $ind1 = substr(@$indicator[$j],0,1);
|
||||
my $ind2 = substr(@$indicator[$j],1,1);
|
||||
$xml.="<datafield tag=\"@$tags[$i]\" ind1=\"$ind1\" ind2=\"$ind2\">\n";
|
||||
$first=0;
|
||||
}
|
||||
$xml.="<subfield code=\"@$subfields[$i]\">@$values[$i]</subfield>\n";
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (@$values[$i] eq "") {
|
||||
}
|
||||
else {
|
||||
if ($first){
|
||||
my $ind1 = substr(@$indicator[$j],0,1);
|
||||
my $ind2 = substr(@$indicator[$j],1,1);
|
||||
$xml.="<datafield tag=\"@$tags[$i]\" ind1=\"$ind1\" ind2=\"$ind2\">\n";
|
||||
$first=0;
|
||||
}
|
||||
$xml.="<subfield code=\"@$subfields[$i]\">@$values[$i]</subfield>\n";
|
||||
}
|
||||
}
|
||||
$prevtag = @$tags[$i];
|
||||
}
|
||||
$xml.= MARC::File::XML::footer();
|
||||
# warn $xml;
|
||||
$prevtag = @$tags[$i];
|
||||
}
|
||||
$xml.= MARC::File::XML::footer();
|
||||
warn $xml;
|
||||
return $xml
|
||||
}
|
||||
sub MARChtml2marc {
|
||||
|
|
@ -2994,8 +2995,12 @@ Paul POULAIN paul.poulain@free.fr
|
|||
|
||||
# $Id$
|
||||
# $Log$
|
||||
# Revision 1.115.2.45 2006/03/08 10:49:36 tipaul
|
||||
# deal with &, <, >,", ' that are not valid in a XML file.
|
||||
# Revision 1.115.2.46 2006/03/08 16:31:04 kados
|
||||
# bugfix for Biblio.pm based on feedback from production system. previous
|
||||
# version was dropping subfields in cases where the previous tag in the
|
||||
# editor contained values (but only when multiple subfields existed in
|
||||
# both tags). This version will be tested again in production environment
|
||||
# to ensure it is actually fixed.
|
||||
#
|
||||
# Revision 1.115.2.44 2006/03/01 17:26:08 kados
|
||||
# Adding 'use MARC::File::XML' to routine ... needed for additem.pl to work
|
||||
|
|
|
|||
Loading…
Reference in New Issue