From e8237ef214080a52bb0f097cca0f4490041219d1 Mon Sep 17 00:00:00 2001 From: amillar Date: Wed, 26 Jun 2002 15:52:55 +0000 Subject: [PATCH] Fix display of marc tag labels and indicators --- C4/SimpleMarc.pm | 28 ++++++++++++++++-- acqui.simple/marcimport.pl | 60 +++++++++++++++++++++++++++++--------- 2 files changed, 72 insertions(+), 16 deletions(-) diff --git a/C4/SimpleMarc.pm b/C4/SimpleMarc.pm index 8b4358ee42..0281dc0334 100755 --- a/C4/SimpleMarc.pm +++ b/C4/SimpleMarc.pm @@ -30,6 +30,7 @@ $VERSION = 0.01; @EXPORT = qw( &extractmarcfields &parsemarcfileformat + &taglabel %tagtext %tagmap ); @@ -75,6 +76,7 @@ my $priv_func = sub { # Constants my %tagtext = ( + 'LDR' => 'Leader', '001' => 'Control number', '003' => 'Control number identifier', '005' => 'Date and time of latest transaction', @@ -82,14 +84,18 @@ my %tagtext = ( '007' => 'Physical description fixed field', '008' => 'Fixed length data elements', '010' => 'LCCN', - '015' => 'LCCN Cdn', + '015' => 'National library CN', '020' => 'ISBN', '022' => 'ISSN', + '024' => 'Other standard ID', + '035' => 'System control number', '037' => 'Source of acquisition', '040' => 'Cataloging source', '041' => 'Language code', '043' => 'Geographic area code', + '043' => 'Publishing country code', '050' => 'Library of Congress call number', + '055' => 'Canadian classification number', '060' => 'National Library of Medicine call number', '082' => 'Dewey decimal call number', '100' => 'Main entry -- Personal name', @@ -352,9 +358,9 @@ sub parsemarcfileformat { my $field; my $leader=substr($record,0,24); - print "Leader:$leader\n" if $debug; + print "
parse Leader:$leader
\n" if $debug; push (@record, { - 'tag' => 'Leader', + 'tag' => 'LDR', 'indicator' => $leader , } ); @@ -364,6 +370,7 @@ sub parsemarcfileformat { my $tag; my $indicator; unless ($directory) { + # If we didn't already find a directory, extract one. $directory=$field; my $itemcounter=1; my $counter2=0; @@ -371,9 +378,12 @@ sub parsemarcfileformat { my $length; my $start; while ($item=substr($directory,0,12)) { + # Pull out location of first field $tag=substr($directory,0,3); $length=substr($directory,3,4); $start=substr($directory,7,6); + + # Bump to next directory entry $directory=substr($directory,12); $tag{$counter2}=$tag; $counter2++; @@ -387,6 +397,7 @@ sub parsemarcfileformat { my @subfields=split(/$splitchar3/, $field); $indicator=$subfields[0]; $field{'indicator'}=$indicator; + print "
parse indicator:$indicator
\n" if $debug; my $firstline=1; unless ($#subfields==0) { my %subfields; @@ -427,8 +438,19 @@ sub parsemarcfileformat { return @records; } # sub parsemarcfileformat +#---------------------------------------------- +sub taglabel { + my ($tag)=@_; + + return $tagtext{$tag}; + +} # sub taglabel + #--------------------------------------------- # $Log$ +# Revision 1.1.2.2 2002/06/26 15:52:55 amillar +# Fix display of marc tag labels and indicators +# # Revision 1.1.2.1 2002/06/26 07:27:35 amillar # Moved acqui.simple MARC handling to new module SimpleMarc.pm # diff --git a/acqui.simple/marcimport.pl b/acqui.simple/marcimport.pl index da83292fff..131df99b7f 100755 --- a/acqui.simple/marcimport.pl +++ b/acqui.simple/marcimport.pl @@ -1017,55 +1017,86 @@ sub FormatMarcText { $fields, # list ref to MARC fields )=@_; # Return + my $marctext; my ( - $marctext, $color, $field, $tag, $label, + $indicator, $subfieldcode,$subfieldvalue, @values, $value ); + my $debug=0; - #return "MARC text here"; + #----------------------------------------- - $marctext=" - \n"; } # foreach field @@ -1079,6 +1110,9 @@ sub FormatMarcText { #--------------- # $Log$ +# Revision 1.6.2.27 2002/06/26 15:52:55 amillar +# Fix display of marc tag labels and indicators +# # Revision 1.6.2.26 2002/06/26 14:28:35 amillar # Removed subroutines now existing in modules: extractmarcfields, # parsemarcfileformat, addz3950queue, getkeytableselectoptions -- 2.39.5
+ $marctext=" + \n"; foreach $field ( @$fields ) { + + # Swap colors on alternating lines ($color eq $lc1) ? ($color=$lc2) : ($color=$lc1); + $tag=$field->{'tag'}; - $label=$tagtext{$tag}; - if ( $tag eq 'Leader' ) { + $label=taglabel($tag); + + if ( $tag eq 'LDR' ) { $tag=''; $label="Leader:"; } + print "
Format tag=$tag label=$label
\n" if $debug; + $marctext.=" \n" . " \n"; - if ( ! $field->{'subfields'} ) { - $marctext.=""; + + $indicator=$field->{'indicator'}; + $indicator=~s/ +$//; # drop trailing blanks + + # Third table column has indicator if it is short. + # Fourth column has embedded table of subfields, and indicator + # if it is long (leader or fixed-position fields) + + print "
Format indicator=$indicator" .
+		" length=" . length( $indicator ) .  "
\n" if $debug; + if ( length( $indicator <= 3 ) ) { + $marctext.="" . + "" . + "\n"; + $marctext.="
MARC RECORD
$label$tag$field->{'indicator'}
" .
+		"$indicator
" ; } else { + $marctext.="" . + "$indicator "; + } # if length + + # Subfields + if ( $field->{'subfields'} ) { # start another table for subfields - $marctext.="\n " . - " \n"; + $marctext.= "
\n"; foreach $subfieldcode ( sort( keys %{ $field->{'subfields'} } )) { $subfieldvalue=$field->{'subfields'}->{$subfieldcode}; if (ref($subfieldvalue) eq 'ARRAY' ) { - # if it's a pointer to array, get the values + # if it's a pointer to array, get all the values @values=@{$subfieldvalue}; } else { + # otherwise get the one value @values=( $subfieldvalue ); } # if subfield array foreach $value ( @values ) { - $marctext.="" . + $marctext.="" . "\n"; } # foreach value } # foreach subfield - $marctext.="
$subfieldcode
$subfieldcode$value
\n"; } # if subfields + # End of indicator and subfields column + $marctext.="\n"; + + # End of columns $marctext.="