Changeset 27141

Show
Ignore:
Timestamp:
28.03.2013 11:10:39 (7 years ago)
Author:
kjdon
Message:

fixed extract_metadata so that it will get all ocurrences of a subfield, not just the first one. NOTE, haven't done the same for extract_ascii_metadata

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • main/trunk/greenstone2/perllib/plugins/MARCPlugin.pm

    r27106 r27141  
    333333} 
    334334 
    335  
    336335sub extract_metadata 
    337336{ 
     
    357356        $subfield = $2; 
    358357    } 
    359     if (defined $subfield) { 
    360         my $meta_value = $marc->subfield($marc_field, $subfield); 
     358 
     359    foreach my $meta_value_obj ($marc->field($marc_field)) { 
     360        my $meta_value; 
     361        if (defined($subfield)) { 
     362        $meta_value = $meta_value_obj->subfield($subfield); 
     363        } else { 
     364        $meta_value = $meta_value_obj->as_string(); 
     365        } 
    361366        if (defined $meta_value) { 
    362         # Square brackets in metadata values need to be escaped so they don't confuse Greenstone/GLI 
    363         $meta_value =~ s/\[/&\#091;/g; 
    364         $meta_value =~ s/\]/&\#093;/g; 
    365         my $metavalue_str = $self->to_utf8($encoding, $meta_value); 
    366         $doc_obj->add_utf8_metadata ($section, $gsdl_field, $metavalue_str); 
    367         } 
    368     } 
    369     else 
    370     { 
    371         foreach my $meta_value_obj ($marc->field($marc_field)) 
    372         { 
    373         my $meta_value = $meta_value_obj->as_string(); 
    374  
    375367        # Square brackets in metadata values need to be escaped so they don't confuse Greenstone/GLI 
    376368        $meta_value =~ s/\[/&\#091;/g;