From 90e93e3a4dd1b03ffc00ffc1287acdfde28b33df Mon Sep 17 00:00:00 2001 From: kados Date: Wed, 8 Mar 2006 16:31:04 +0000 Subject: [PATCH] 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. --- C4/Biblio.pm | 83 ++++++++++++++++++++++++++++------------------------ 1 file changed, 44 insertions(+), 39 deletions(-) diff --git a/C4/Biblio.pm b/C4/Biblio.pm index 3f6f8418ae..8c5d68bcb7 100644 --- a/C4/Biblio.pm +++ b/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; + #warn "IND:".substr(@$indicator[$j],0,1).substr(@$indicator[$j],1,1)." ".@$tags[$i]; if (!$first){ - $xml.="\n"; - $first=1; + $xml.="\n"; + if (@$tags[$i] > 10) { + my $ind1 = substr(@$indicator[$j],0,1); + my $ind2 = substr(@$indicator[$j],1,1); + $xml.="\n"; + $xml.="@$values[$i]\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.="@$values[$i]\n"; $first=1; - # rest of the fixed fields - } elsif (@$tags[$i] < 10) { + # rest of the fixed fields + } elsif (@$tags[$i] < 10) { $xml.="@$values[$i]\n"; $first=1; - } - else { + } else { my $ind1 = substr(@$indicator[$j],0,1); my $ind2 = substr(@$indicator[$j],1,1); $xml.="\n"; $xml.="@$values[$i]\n"; $first=0; - } - } - } - } else { - if (@$values[$i] eq "") { + } + } } - else { - if ($first){ - my $ind1 = substr(@$indicator[$j],0,1); - my $ind2 = substr(@$indicator[$j],1,1); - $xml.="\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.="\n"; + $first=0; + } + $xml.="@$values[$i]\n"; } - $xml.="@$values[$i]\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 -- 2.39.5