--- trunk/lib/WebPAC/Normalize/MARC.pm 2007/11/12 11:57:00 1038 +++ trunk/lib/WebPAC/Normalize/MARC.pm 2007/11/12 12:13:57 1039 @@ -58,6 +58,8 @@ =cut +my $created_with_marc_template; + sub marc_template { my $args = {@_}; warn "## marc_template(",dump($args),")",$/ if $debug; @@ -134,7 +136,10 @@ my $i1 = $r->{i1} || ' '; my $i2 = $r->{i2} || ' '; - $m = [ $args->{to}, $i1, $i2 ]; + my $to = $args->{to}; + $m = [ $to, $i1, $i2 ]; + + $created_with_marc_template->{ $to }++; warn "### r = ",dump( $r ),$/ if $debug; @@ -610,6 +615,8 @@ return $#{ $marc_record }; } +=head1 PRIVATE FUNCTIONS + =head2 _marc_push _marc_push( $marc ); @@ -621,8 +628,6 @@ push @{ $marc_record->[ $marc_record_offset ] }, $marc; } -=head1 PRIVATE FUNCTIONS - =head2 _clean Clean internal structures @@ -630,7 +635,7 @@ =cut sub _clean { - ($marc_record, $marc_encoding, $marc_repeatable_subfield, $marc_indicators, $marc_leader) = (); + ($marc_record, $marc_encoding, $marc_repeatable_subfield, $marc_indicators, $marc_leader, $created_with_marc_template) = (); ($marc_record_offset, $marc_fetch_offset) = (0,0); } @@ -644,6 +649,8 @@ We are using I which detect repeatable fields only from sequence of field/subfield data generated by normalization. +This magic is disabled for all records created with C. + Repeatable field is created when there is second occurence of same subfield or if any of indicators are different. @@ -715,9 +722,9 @@ # first, sort all existing fields # XXX might not be needed, but modern perl might randomize elements in hash - my @sorted_marc_record = sort { - $a->[0] . ( $a->[3] || '' ) cmp $b->[0] . ( $b->[3] || '') - } @{ $marc_rec }; +# my @sorted_marc_record = sort { +# $a->[0] . ( $a->[3] || '' ) cmp $b->[0] . ( $b->[3] || '') +# } @{ $marc_rec }; @sorted_marc_record = @{ $marc_rec }; ### FIXME disable sorting @@ -752,6 +759,11 @@ my $row = dclone( $sorted_marc_record[$i] ); + if ( $created_with_marc_template->{ $row->[0] } ) { + push @m, $row; + warn "## copied marc_template created ", dump( $row ),$/ if $debug; + next; + } # field and subfield which is key for # marc_repeatable_subfield and u my $fsf = $row->[0] . ( $row->[3] || '' );