#!usr/local/bin/perl use English; #require("cgi-lib.pl"); # 21. januar 1999 Tone Merete Bruvik # Last changed: 27th July 1999 TMB: Translate smale sample from KALLIAS from DLA, OK. # Program reading export file from collections and translate then into EAD format an vica versa. # Copyright (C) 1999 Tone Merete Bruvik , HIT - The Humanities Information Technologies Research Programme # at the University of Bergen # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details: http://www.gnu.org/copyleft/gpl.html # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. # # Made for the MALVINE project, # # Reading each record from the imputfile, translate into EAD, writing an output file # # Arguments: if arguments are provided they must look like this: # # # The collections identifier have to be one of catalogues indentify in the table "CollInfo.txt", or # it can by "EAD". # # On MacOS: If arguments are not given, the user is asked for the information in the order given above. # On UNIX/ PC: If arguments are not given, an error message is given, and the script dies. # # If the input file contains lines which the script can't translate, these lines are written at the # end of each component # Some flags $ekskluder = 0; $prompt1 = "Choose input file"; $prompt2 = "Give a name for the output file:"; $inFormat = ''; $errorFile = 1; # If this variable is 1 (true), then input lines which there is found no matches # are written to an error file. If its 0, then these lines are written last in each component # If fixedArguments is set, then the program will not ask for input arguments on a Mac, but using these. # The fixedArguments may contain one or many file references, in case there is more than one, all # the refereced files will be converted. @fixedArguments = (#["BLindex.txt","BL","BLindex.xml","XML"], #["BLkonkat.html","BL_cat_desc","BLcat.xml","XML"], #["BN.marc","BN","BN.xml","XML"], #["DLA_kallias.text","Kallias","DLA_kallias.xml","XML"], #["FDOP.eks","FDOP","FDOP.xml","XML"], #["GSA.eks","GSA","GSA.xml","XML"], #["IMEC.txt","IMEC","IMEC.xml","XML"], #["KGS.001","KGS","KGS.xml","XML"], #["NMD.eks","NMD","NMD.xml","XML"], #["OLA.eks","OLA","OLA.xml","XML"], #["SBBdoc.eks","SBB_doc","SBBdoc.xml","XML"], #["SBBpers.eks","SBB_pers","SBBpers.xml","XML"], #["SLA.eks","SLA","SLA.xml","XML"], #["UCM.MARC","UCM","UCM.xml","XML"] ); # Some variables $fieldStart = ''; # clean the field start string @theRecord = ''; # clean the record string $outFormat = 'SGML'; # Default $recordCount = 0; #&ReadParse(*input); #print("content-type: text/html\n\n"); &makeCollTab; &makeExprTab; &makeTermTab; if ($errorFile == 1) { open(ERRORFILE,">".($errorfilnavn = "ERROR.TXT")) || die("Something went wrong when open ERRORFILE"); } ($sec, $min,$hour) = localtime(time); print ("Start time:", $hour,":",$min,":",$sec, "\n"); print ERRORFILE ("Start time:", $hour,":",$min,":",$sec, "\n"); if (@input > 0) { # There are given input arguments open(INNFIL,$innf = $input{inputFile}) || die("Input file does not work\n"); open(UTFIL,">".($utfilnavn = $input{outputFile})) || die("Output file does not work\n"); $inFormat = $input{inputFileType}; if ($inFormat =~ /[$validCollStr, EAD]/) { } else { print ("List of valid formats: ", $validCollStr, ", EAD \n"); die("The given collection is ($inFormat) is not a valid one\n"); } #The SGML/XML format can be empty, which means SGML is going to be used, # or it can be XML or SGML. $outFormat = $input{outputFileType}; if ($outFormat =~ /[$validCollStr,SGML,XML]/) { } else { print ("List of valid output formats: ", $validCollStr,", SGML, XML \n"); die("The given output format ($outFormat) is not a valid format.\n"); } &convertOneFile; } else { # There is not given input paramteres if (@ARGV < 1) { # Test which platform the program is running on if ($OSNAME =~/MacOS/) { require "StandardFile.pl"; print("2MALVINE starts (without arguments). Operating system running: $OSNAME\n"); #Check if a fixed set of input variables are used if (@fixedArguments + 0 > 0) { for $i (0..$#fixedArguments) { print ("Fixed set of arguments:\n"); print ("Input file: ", $fixedArguments[$i][0]); print (". Input format: ", $fixedArguments[$i][1]); print (". Output file: ", $fixedArguments[$i][2]); print (". Output format: ", $fixedArguments[$i][3],"\n"); open(INNFIL,$fixedArguments[$i][0]) || die("Something went wrong in the GetFile dialog\n"); print ("Collection available: ", $validCollStr, "\n"); $inFormat = $fixedArguments[$i][1]; open(UTFIL,">".$fixedArguments[$i][2]) || die("Something went wrong in the PutFile dialog"); $outFormat = $fixedArguments[$i][3]; &MacPerl'SetFileInfo("MSWD","TEXT",$utfilnavn); @theRecord = ''; # clean the record string $recordCount = 0; &convertOneFile; } } else { open(INNFIL,$innf = &StandardFile'GetFile($prompt, ("TEXT"))) || die("Something went wrong in the GetFile dialog\n"); print ("Collection available: ", $validCollStr, "\n"); $inFormat = MacPerl::Pick("What kind of file is the input file?", @validCollArray, EAD); open(UTFIL,">".($utfilnavn = &StandardFile'PutFile($prompt2, "UtDCD"))) || die("Something went wrong in the PutFile dialog"); if ($inFormat =~ /EAD/) { $outFormat = MacPerl::Pick("Which formats do you want the output file to have?",@validCollArray); } else { $outFormat = MacPerl::Pick("Which formats do you want the output file to have?", SGML, XML); } &MacPerl'SetFileInfo("MSWD","TEXT",$utfilnavn); # Convert the file selected &convertOneFile; } } else { #Run on PC or UNIX: the arguments have to be used. die("No arguments given. Run the script with arguments: , , \n"); } } else { print("2MALVINE starts (with arguments). Operating system running: $OSNAME\n"); print("The arguments should be given like this:\n"); print(" \n"); print("For instance like this: 2malvine.pl NMD.eks NMD.XML NMD XML\n"); print("The given arguments:\n"); print("Input file: ",$ARGV[0]," Output file: ",$ARGV[1]," Input format: ",$ARGV[2]," Output format: ",$ARGV[3],"\n"); open(INNFIL,$innf = $ARGV[0]) || die("ARGV-input file does not work\n"); open(UTFIL,">".($utfilnavn = $ARGV[1])) || die("ARGV-output file does not work\n"); $inFormat = $ARGV[2]; if ($inFormat =~ /[$validCollStr, EAD]/) { } else { print ("List of valid formats: ", $validCollStr, ", EAD \n"); die("The given collection is ($inFormat) is not a valid one\n"); } #The SGML/XML format can be empty, which means SGML is going to be used, # or it can be XML or SGML. $outFormat = $ARGV[3]; if ($outFormat =~ /[$validCollStr,SGML,XML]/) { } else { print ("List of valid output formats: ", $validCollStr,", SGML, XML \n"); die("The given output format ($outFormat) is not a valid format.\n"); } # Convert the file selected &convertOneFile; } } ($sec, $min,$hour) = localtime(time); print("End time:", $hour,":",$min,":",$sec, "\n"); print ERRORFILE ("End time:", $hour,":",$min,":",$sec, "\n"); print("Open the file 'ERROR.TXT' to have an overview of lines from the input file which are not converted. \n"); close(ERRORFILE); print("Done\n"); ############################################ # Sub rutine: From EAD to local format # PS! This version using the conversion table # TMB 4/3-99 sub convertOneFile { my ($outFormat) = @_; if ($inFormat =~ /EAD/) { # Make the conversion tables &makeConTab($inFormat); &makeConTab2($outFormat); &makeCharConvTable($collectionInfo{$outFormat}{"charcode"}); $fieldStart = '<.+>'; &convertOneFile($outFormat); } else { print("From Local to EAD format. Input format: ",$inFormat,"\n"); # Read in a record from the file, we have to known the record seperator for each type # of imput format # Make the conversion tables &makeConTab($inFormat); &makeCharConvTable($collectionInfo{$inFormat}{"charcode"}); $fieldStart = $collectionInfo{$inFormat}{"fieldStart"}; $fieldEnd = $collectionInfo{$inFormat}{"fieldEnd"}; $language = $collectionInfo{$inFormat}{"language"}; $encoding_system = $collectionInfo{$inFormat}{"Encoding_system"}; print("Providers short name:", $collectionInfo{$inFormat}{"Providers short name"},"\n"); print("Collection type:", $collectionInfo{$inFormat}{"Collection type"},"\n"); print("Provider full name:", $collectionInfo{$inFormat}{"Provider Full name"},"\n"); print("Collections full name:", $collectionInfo{$inFormat}{"Collections full name"},"\n"); print ERRORFILE ("Collections full name:", $collectionInfo{$inFormat}{"Collections full name"},"\n"); print("Description:", $collectionInfo{$inFormat}{"Description"},"\n"); print("Language: $language\n"); print("Char encoding:", $collectionInfo{$inFormat}{"charcode"},"\n"); print("Encoding system:", $encoding_system,"\n"); print("Field start tag:", $collectionInfo{$inFormat}{"fieldStart"},"\n"); print("Field end tag:", $collectionInfo{$inFormat}{"fieldEnd"},"\n"); print("FieldStart:", $fieldStart,"\n"); print("FieldEnd:", $fieldEnd,"\n"); print("Record start tag:", $collectionInfo{$inFormat}{"recordStart"},"\n"); print("Record end tag:", $collectionInfo{$inFormat}{"recordEnd"},"\n"); &readLocalfile($inFormat); } close(INNFIL); close(UTFIL); } ############################################ # Sub rutine: From EAD to local format # PS! This version using the conversion table # TMB 4/3-99 sub readEADfile { my ($outFormat) = @_; $line =''; # Scipping everything until the first print ("The format for the output file:",$outFormat, "\n"); $line = ; while ($line !~ //){ $line = ; } # Reading each record in the input file $fieldnr = 0; while ($line = ) { $linenr++; # Remove any , , or elements, and so on $line =~s/(.*)(.*)/$1$2/; $line =~s/(.*)<\/did>(.*)/$1$2/; $line =~s/(.*)(.*)/$1$2/; $line =~s/(.*)<\/admininfo>(.*)/$1$2/; $line =~s/(.*)(.*)/$1$2/; $line =~s/(.*)<\/controlaccess>(.*)/$1$2/; $line =~s/(.*)(.*)/$1$2/; $line =~s/(.*)<\/add>(.*)/$1$2/; $line =~s/(.*)(.*)/$1$2/; $line =~s/(.*)<\/bibhist>(.*)/$1$2/; $line =~s/(.*)(.*)/$1$2/; $line =~s/(.*)<\/dsc><\/ARCHDESC><\/EAD>(.*)/$1$2/; # If last line containt , it was a end of one record if ($line =~/<\/c01>/) { # Convert the current record into an local compoment $record = make_LocalComponent($outFormat, @theRecord); # print the previous record to the file print UTFIL ($record); @theRecord = (); # clean the record $fieldnr = 0; } else { # Collect the lines into one record. # $line = to_SGMLletters($line); if ($line =~ /^<.+>/) { $fieldnr++; @theRecord[$fieldnr] = $line; } else { #Remove the linebreak at the end of @theRecord[$fieldnr] @theRecord[$fieldnr] =~ s/(.)\n/$1/; # If the new line does not begin with a whitespace char, add one if ($line =~ /^\s/) { @theRecord[$fieldnr] = @theRecord[$fieldnr].$line; } else { @theRecord[$fieldnr] = @theRecord[$fieldnr]." ".$line; } } } } #while # print the last record to the file print UTFIL ($record); } ############################################ # Sub rutine: From Local to EAD # PS! This version using the conversion table # TMB 26/2-99 sub readLocalfile { my ($inFormat) = @_; $line = ''; $recordEnd = $collectionInfo{$inFormat}{"recordEnd"}; #print("Her er readLocalfile1\n"); $line = make_Header($inFormat,$language); print UTFIL ($line); $line = make_Frontmatter($inFormat); print UTFIL ($line); $line = make_startColl($inFormat); print UTFIL ($line); #print("Her er readLocalfile2\n"); # Check if we are using field start or end tag if (length ($fieldStart) >0) { $seachnewline = '^'.$fieldStart; #print("seachnewline: ",$seachnewline, "\n"); } elsif (length ($fieldEnd) >0) { $seachnewline = $fieldEnd.'$'; #print("seachnewline: ",$seachnewline, "\n"); } else { # Using none, then each line is a separat field #print("Error in readLocalfile:fieldStart: ",$fieldStart,"fieldEnd: ",$fieldEnd, "\n"); } # Reading each line from the input file $fieldnr = 0; while ($line = ) { $lineNr++; # Translate diacritical characters $line = to_UNICODE($line,$collectionInfo{$inFormat}{"charcode"}); # print($lineNr,": ",$line, "\n"); # Remove any leading empty space at the input line $line =~s/^\s(.+)/$1/; #print("Line1:",$line,"\n"); #print("Line2:",$line,"\n"); # Each record is normaly separted by a empty line, but some collection using # start record/end record strings. if (((length($collectionInfo{$inFormat}{"recordEnd"}) < 1) && (length($line) < 3) && ($lineNr > 1 )) || ((length($collectionInfo{$inFormat}{"recordEnd"}) > 0) && ($line =~ /$recordEnd/))){ #This line is the last line in the record (if not empty) $fieldnr++; @theRecord[$fieldnr] = @theRecord[$fieldnr].$line; #print("Her er readLocalfile 2: record ",@theRecord,"\n"); # Convert the current record into an EAD Compoment if ($collectionInfo{$inFormat}{"Collection type"} =~ /Authority/) { $record = make_EADBioghist($inFormat, @theRecord); } else { $record = make_EADComponent($inFormat, @theRecord); #end the component $record = $record.&make_endItem('EAD','01'); } # print the previous record to the file print UTFIL ($record); #print("Her er readLocalfile 2: record ",$record,"\n"); @theRecord = (); # clean the record $fieldnr = 0; } else { # Collect the lines into one record. The linebreaks are removed, and new linebreaks between # each field of the record is inserted (which is usually at the same position as the original # ones, but if there at linebreaks inside a field, they are removed, and if there are no # linebreaks, they are inserted #print("Her er readLocalfile4,5: linje ",$line,"\n"); if ($line =~ /$seachnewline/) { $fieldnr++; @theRecord[$fieldnr] = @theRecord[$fieldnr].$line; #print("Her er readLocalfile5: linje ",$line,"\n"); } else # We have a case where there is an linebreak inside a field { # If this import file have fieldStart tags if (length ($fieldStart) >0) { #Remove the linebreak at the end of @theRecord[$fieldnr] @theRecord[$fieldnr] =~ s/(.+)\n/$1/; #print("Her er readLocalfile6: linje ",$line,"\n"); # If the new line does not begin with a whitespace char, add one if ($line =~ /^\s/) { if ($inFormat == 'Kallias') { #Remove any starting space intil the "=" $line =~ s/\s+=(.+)/$1/; } @theRecord[$fieldnr] = @theRecord[$fieldnr].$line; } else { @theRecord[$fieldnr] = @theRecord[$fieldnr]." ".$line; } } else { #This line the beginning of the next line #Remove the linebreak at the end the line $line =~ s/(.+)\n/$1/; @theRecord[$fieldnr+1] = $line; } #print("Her er readLocalfile7: linje ",$line,"\n"); #print("Her er readLocalfile7: record, linjenr ",$fieldnr,":",@theRecord[$fieldnr],"\n"); } } } #while # Make the last component of the collection if ($collectionInfo{$inFormat}{"Collection type"} =~ /Authority/) { $record = make_EADBioghist($inFormat, @theRecord); } else { $record = make_EADComponent($inFormat, @theRecord); #end the component $record = $record.&make_endItem('EAD','01'); } # print the last record to the file print UTFIL ($record); # End the collection $line = make_endColl(); print UTFIL ($line); } ############################################ # Sub rutine: Make the current record ready for printing # TMB 22/1-99 # # Translate content of theRecord into an record. sub make_LocalComponent { my ($inFormat, @theRecord) = @_; $fieldnr = 0; $errors = ''; # clean the error part $line = ''; # clean the line $record = ''; # Encode the previous record lines for lines $noField = @theRecord + 0; $record = make_startItem('',$inFormat,''); while ($fieldnr <= $noField) { $fieldnr++; $line = conv_2local(@theRecord[$fieldnr],$inFormat); $record = $record.$line."\n"; } $record = $record.make_endItem($inFormat,''); return $record; } ############################################ # Sub rutine: Make the current record ready for printing # TMB 22/1-99 # # Translate content of theRecord into an element in EAD encoding. sub make_EADComponent { my ($inFormat, @theRecord) = @_; $fieldnr = 0; $cAttr = ''; # clean the attributes to the C element %attr_list = (); # clean the attributelist $attCount = 0; $didPart = ''; # clean the did part of the record $admPart = ''; # clean the admininfo part of the record $accPart = ''; # clean the controlaccess part of the record $addPart = ''; # clean the add part of the record $bioghistPart = ''; # clean the bioghist part of the record $endSubPart = ''; # clean the endSubPart part of the record $errors = ''; # clean the error part $line = ''; # clean the line $collectionLevel = "01"; $gattung = 0; # Used by the convertions of DLA collections, keep track of if a gattung is open or closed. # Encode the previous record field for field $noField = @theRecord + 0; $recordCount++; while ($fieldnr <= $noField) { #print ("1",@theRecord[$fieldnr],"\n"); $line = conv2EAD(@theRecord[$fieldnr],$collectionInfo{$inFormat}{"Encoding_system"}); #print ("2",$line,"\n"); # If SGML version is the selected format for the output, check for espesially XML things if ($outFormat =~ /SGML/) { if ($line =~ s/(.+<.+)/$1$2/) { #print ($line,"\n"); } } # Test if this is the catalogue from DLA encodied in TEX and if this line start a # gattung-element if ($inFormat == 'DLA') { #print ("Record: ",@theRecord[$fieldnr],"\n"); if (@theRecord[$fieldnr] =~ /\\gattung/) { # If a gattung allready was started, then this gattung ends here if ($gattung == 1) { $line = "<\/unittitle>".$line; #print ("1Line: ", $line,"\n"); } $gattung = 1; # gattung starts } elsif ((@theRecord[$fieldnr] =~ /\\end\{bestand\}/) || (@theRecord[$fieldnr] =~ /\\begin/)) { if ($gattung == 1) { $line = "<\/unittitle>".$line; #print ("2Line: ", $line,"\n"); } $gattung = 0; # gattung ends } elsif ((@theRecord[$fieldnr] =~ /\\end/)) { if ($gattung == 1) { $line = "<\/unittitle><\/did>".$line; #print ("3Line: ", $line,"\n"); } $gattung = 0; # gattung ends } elsif ($fieldnr == $noField) { if ($gattung == 1) { $line = "<\/unittitle>".$line; #print ("4Line: ", $line,"\n"); } $gattung = 0; # gattung ends } elsif ($line =~ /\\name(.*)>/) { # Take a extra check if there are some names still not converted if ($gattung == 1) { print ("Name: ", $line,"\n"); } else { print ("Feil! Name: ", $line,"\n"); } } } #print ("2.",$line,"\n"); # Check if the line is a attribute line or a element to go inside an other element. if ($line =~ //) { # Special case, have to keep the attributes in a record #print ("start of a collection:",$line,"\n"); $attr_list[$attCount] = $line; #print ("attCount:",$attCount, @attr_list[$attCount],"\n"); $attCount++; } elsif ($line =~ //) { # Special case, have to keep the attributes in a record #print ("start of a collection:",$line,"\n"); $attr_list[$attCount] = $line; #print ("attCount:",$attCount, @attr_list[$attCount],"\n"); $attCount++; } elsif ($line =~ //) { # This is a start of a subcollection $collectionLevel = "02"; $cAttr = $1; #print ("collectionLevel:",$collectionLevel,"\n"); #print ("attributts:",$cAttr,"\n"); } elsif ($line =~ /<\/c02>/) { # This is a end of subcollection $endSubPart = $line; #print ("endSubPart: ", $endSubPart,"\n"); } elsif ($line =~ //) { $line =~ s/(.+)/$1/; $didPart = $didPart.$line; } elsif ($line =~ //) { $line =~ s/(.+)/$1/; $admPart = $admPart.$line; } elsif ($line =~ //) { $line =~ s/(.+)/$1/; $accPart = $accPart.$line; } elsif ($line =~ //) { $line =~ s/(.+)/$1/; $addPart = $addPart.$line; } elsif ($line =~ //) { $line =~ s/(.+)/$1/; $bioghistPart = $bioghistPart.$line; } elsif ($line =~ /<\/unittitle>/) { $didPart = $didPart.$line; #print ("didPart: ", $didPart,"\n"); } elsif ($line =~ /\w+/) { # If the contains some kind of text, then there is an error $errors = $errors.$line; #print ("error:",$errors,"\n"); } else { #print ("test:",$line); } $fieldnr++; } #while $record = make_startItem($cAttr,'EAD',$collectionLevel); # If this is collection level 02, then the DID element is closed when the //end {uterbestand is reachd if ($collectionLevel == '02' ) { $record = $record."".$didPart."\n"; } # The work with adding attributes and elements inside other elements is done, # Put the didpart into to the final record. $record = $record."".$didPart."<\/did>\n"; if (length($admPart) > 1 ) { $record = $record."".$admPart."<\/admininfo>\n"; } if (length($accPart) > 1 ) { $record = $record."".$accPart."<\/controlaccess>\n"; } if (length($addPart) > 1 ) { $record = $record."".$addPart."<\/add>\n"; } if (length($bioghistPart) > 1 ) { $record = $record."".$bioghistPart."<\/bioghist>\n"; } if (length($endSubPart) > 1 ) { $record = $record.$endSubPart; } if (length($errors) > 1 ) { print ("Unmatched line in record ",$recordCount,":\n",$errors, "\n"); if ($errorFile ==1) { print ERRORFILE ("Unmatched line in record ",$recordCount,":\n",$errors); } else { $record = $record.$errors; } } # Check if there are attributes or element to be added to some of the other elements: $record = handle_Attr_Add($record,$attLine); # The attribute localID which is used to identify the elements when attributes and # other elements are added ,has to be removed as it is not an valid EAD attribute $record =~ s/localID\s=\s\'\w+\'//g; # Translate regular expression in the record $record = translateExpressions($inFormat, $record); #print ("Record # ",$recordCount,"."); return $record; } ############################################ # Sub rutine: Make the current bioghist record ready for printing # only used then the input file is an autority file # TMB 28/4-99 # # Translate content of theRecord into an element. sub make_EADBioghist { my ($inFormat, @theRecord) = @_; $fieldnr = 0; $bioghistPart = ''; # clean the bioghist part of the record $errors = ''; # clean the error part $line = ''; # clean the line # Encode the previous record field for field $noField = @theRecord + 0; #print ("Her er jeg\n"); while ($fieldnr <= $noField) { #print ("Org. line:",@theRecord[$fieldnr],"\n"); $line = conv2EAD(@theRecord[$fieldnr],$collectionInfo{$inFormat}{"Encoding_system"}); #print ("Covn. line:",$line,"\n"); # If SGML version is the selected format for the output, check for espesially XML things if ($outFormat =~ /SGML/) { if ($line =~ s/(.+<.+)/$1$2/) { #print ($line,"\n"); } } $fieldnr++; if ($line =~ //) { $line =~ s/(.+)/$1/; $bioghistPart = $bioghistPart.$line; } # Check if the line is a attribute line or a element to go inside an other element. elsif ($line =~ //) { # Special case, have to keep the attributes in a record #print ("start of a collection:",$line,"\n"); $attr_list[$attCount] = $line; #print ("attCount:",$attCount, @attr_list[$attCount],"\n"); $attCount++; } elsif ($line =~ //) { # Special case, have to keep the attributes in a record #print ("start of a collection:",$line,"\n"); $attr_list[$attCount] = $line; #print ("attCount:",$attCount, @attr_list[$attCount],"\n"); $attCount++; } else { $errors = $errors.$line; } } #while if (length($bioghistPart) > 1 ) { $record = "".$bioghistPart."<\/bioghist>\n"; } # Check if there are attributes or element to be added to some of the other elements: $record = handle_Attr_Add($record,$attLine); if (length($errors) > 1 ) { print ("Unmatched line: ",$errors, "\n"); if ($errorFile ==1) { print ERRORFILE ("Unmatched line: ",$errors); } else { $record = $record.$errors; } } $record = $record.$line."\n"; return $record; } ############################################ # Sub rutine: Put the contents of list over attributes and # additions to elements into the right place in the record # TMB 21/9-99 sub handle_Attr_Add { my ($record,$attLine) = @_; # Check if there are attributes or element to be added to some of the other elements: foreach $attLine (@attr_list) { #print ("attLine:",$attLine,"\n"); if ($attLine =~ s/(.+)/$1/) { # Each attribute line have the name of the element and ID to the element its belongs to, # followed by the attribute and is value if ($attLine =~/<(.+)\slocalID\s=\s(.+)>(.+)=(.+)/) { #print ("2attLine :",$attLine,"\n"); $theElement = $1; $theID = $2; $theAttributeLabel = $3; $theAttributeValue = $4; $sokString = $theElement."(.+localID = ".$theID.")"; # Check through all the lines in the record if ($record =~ /$sokString/m) { $record = $PREMATCH.$theElement." ".$1.$theAttributeLabel." = ".$theAttributeValue.$POSTMATCH; } else { print ("1 Did not find :",$sokString,"\n"); print ("in the record(",$recordCount,"):",$record,"\n"); print ("attLine attLine:",$attLine,"\n"); print ("theElement: ",$theElement,"\n"); print ("theID: ",$theID,"\n"); print ("theAttributes: ",$theAttributes,"\n"); } } elsif ($attLine =~ /(.+)/) { # This is attributes to the element, add them too the c-attribute string $cAttr = $cAttr.$1; #print ("cAttr :",$cAttr,"\n"); } } elsif ($attLine =~ s/(.+)/$1/) { # Each addition to an other element line have the name of the element and ID to the element its belongs to, # followed by the addition #print ("1 attLine:",$attLine,"\n"); if ($attLine =~ /<(.+)\s(localID\s=\s\'\w+\')>(<.+)/) { $theElement = $1; $theID = $2; $theAddition = $3; $sokString = "(".$theElement.".+".$theID.".+)(<\/".$theElement.")"; #print ("2 sokString:",$sokString,"\n"); # Check through all the lines in the record if ($record =~ /$sokString/m) { $record = $PREMATCH.$1.$theAddition.$2.$POSTMATCH; } else { print ("2 Did not find :",$sokString,"\n"); print ("in the record(",$recordCount,"):",$record,"\n"); print ("theElement :",$theElement,"\n"); print ("theID :",$theID,"\n"); print ("theAddition :",$theAddition,"\n"); } } } } return $record; } ############################################ # Sub rutine: Convert from on local format to EAD # PS! This version using the conversion table # TMB 26/2-99 sub conv2EAD { my ($line,$owner) = @_; #print("Input: ", $line, "\n"); #print("owner: ", $owner, "\n"); # Running through the convertion table until the first match foreach $element (sort keys %ConTab){ $SearchString = $ConTab{$element}{$owner}; $ReplaceString = $ConTab{$element}{EAD}; #print("element:",$element); #print(" SearchString:",$SearchString,"\n"); if (length($SearchString) > 1 ) { if ($line =~ s/$SearchString/$ReplaceString/gee) { #print("element:",$element,"\n"); #print("SearchString:",$SearchString,"\n"); #print("ReplaceString:",$ReplaceString,"\n"); #print("line:",$line,"\n"); # Check for unevaluating functions in the replacement if ($line =~ /(.+)(\&getGenre\(.+\))(.+)/) { #print("2: ",$2,". 1 line:", $line,"\n"); $genre = eval($2); $line = $1.$genre.$3."\n"; } if ($line =~ /(.+)(\&getRole\(.+\))(.+)/) { # Remove any * characters $part1 = $1; $theFunction = $2; $part3 = $3; $theFunction =~ s/(.+)\*(.+)/$1$2/; #print("1 line:",$line,"\n "); #print("theFunction:",$theFunction,"\n"); $role = eval($theFunction); #print("2 role:",$role,"\n"); $line = $part1.$role.$part3."\n"; #print("3 line:",$line,"\n"); } if ($line =~ /(.+)(\&getWriting\(.+\))(.+)/) { #print("3 line:",$line,"\n"); $role = eval($2); $line = $1.$role.$3."\n"; } #print("4: line:", $line,"\n"); if ($line =~ s/(\&translateTerm\(.+\))/eval($1)/ge) { #print("5: line:", $line,"\n"); } last; } } } #print("Output: ", $line, "\n"); return $line; } ############################################ # Sub rutine: Convert from on EAD to local format # PS! This version using the conversion table # TMB 4/3-99 sub conv_2local { my ($line,$localID) = @_; my $localCopy = $line; #print("Input: ", $line, "\n"); # Running through the convertion table foreach $element (sort keys %ConTab2){ $SearchString = $ConTab2{$element}{EAD}; $ReplaceString = $ConTab2{$element}{$localID}; #print("SearchString: ", $SearchString); # Check for unevaluating functions in the searchstring if ($SearchString =~ /(.+)(\$owner)(.+)/) { # Find the owner from source $theOwner = "\\w+"; $SearchString = $1.$theOwner.$3."\n"; #print("SearchString1: ", $SearchString); } # If there are functions in the searchstring, evaluate them if ($SearchString =~ /(.+)(\&get\w+\(.+\))(.+)/) { $value = eval($2); #print("SearchString2: ", $SearchString); $SearchString = $1.$value.$3."\n"; } #print("SearchString: ", $SearchString); if (length($SearchString) > 1 ) { if($line =~ s/$SearchString/$ReplaceString/ee) { #print("Sk:",$SearchString); #print("Erstatt:",$ReplaceString,"\n"); } } } # If input and out line is identical, this rutine did not find a mapping, make an error message if ($line =~ /$localCopy/) { print("conv_2local: did not find a mapping for:\n", $localCopy, "\n"); } # print("Result: ", $line, "\n"); return $line; } ############################################ # Sub rutine: Make a EAD header # TMB 22/1-99 sub make_Header { my ($owner,$language) = @_; $line = ''; # If this is going to be a XML version if ($outFormat =~ /XML/) { $line = qq!\n!; $line = $line.qq!\n!; } $line = $line.qq!<\!DOCTYPE ead PUBLIC "-\/\/Society of American Archivists\/\/DTD ead.dtd (Encoded Archival Description (EAD))\/\/EN" "/malvine/ead.dtd">\n!; if ($outFormat =~ /XML/) { # $line = qq![ %eadnotat;]>!; } $line = $line.qq!\n!; $line = $line.qq!\n!; $line = $line.""; $line = $line.$owner."0001\n"; $line = $line.""; $line = $line.''; $line = $line.$collectionInfo{$owner}{"Collections full name"}." at ".$collectionInfo{$owner}{"Provider Full name"}. "\n"; $line = $line.''; $line = $line.(localtime); $line = $line."Encoding done using a PERL script made by Tone Merete Bruvik, The HIT Centre, University of Bergen"; $line = $line.'Finding aid writting in English and '; $line = $line.$language."\n"; #$line = $line.""; $line = $line."\n"; return $line; } ############################################ # Sub rutine: Make a Frontmatter # TMB 22/1-99 sub make_Frontmatter { my ($owner) = @_; $line = "\n"; $line = $line."\n"; $line = $line."".$collectionInfo{$owner}{"Collections full name"}."\n"; $line = $line."Tone Merete Bruvik, "; $line = $line.qq!The HIT Centre\n!; $line = $line." - Humanities Information Technologies Research Programme,"; $line = $line.qq! University of Bergen\n!; $line = $line.""; $line = $line."".$collectionInfo{$owner}{"Provider Full name"}."\n"; $line = $line.""; $line = $line.qq!The xml version of the catalogue is sponsored by the !; $line = $line.qq!MALVINE project!; $line = $line.qq! carried out in the Telematics Applications of Common Interest specific RTD Programme "Telematics for Libraries" of the Commission of the European Communities!; $line = $line."\n"; $line = $line.''; $line = $line.(localtime); $line = $line."\n"; $line = $line.qq!

©1999 $collectionInfo{$owner}{"Provider Full name"}

\n!; return $line; } ############################################ # Sub rutine: Make start of a item # TMB 22/1-99 sub make_startItem { my ($theAttributes, $theFormat, $level) = @_; if ($theFormat =~ /EAD/) { $line = qq!\n!; } elsif ($theFormat =~ /NMD/) { $line = qq!\n!; } return $line; } ############################################ # Sub rutine: Make end of a item # TMB 22/1-99 sub make_endItem { my ($theFormat,$level) = @_; if ($theFormat =~ /EAD/) { $line = qq!<\/c$level>\n!; } elsif ($theFormat =~ /NMD/) { $line = qq!<\/dc-record>\n!; } #print ("make_endItem: ",$theFormat, $level, $line,"\n"); return $line; } ############################################ # Sub rutine: Make start of collection # TMB 22/1-99 sub make_startColl { my ($owner) = @_; $line = ''; $line = $line.qq!!; $line = $line.qq!$owner!; $line = $line.qq!!; if ($collectionInfo{$inFormat}{"Collection type"} =~ /Collection/) { $line = $line.qq!\n!; } return $line; } ############################################ # Sub rutine: Make end of collection # TMB 22/1-99 sub make_endColl { if ($collectionInfo{$inFormat}{"Collection type"} =~ /Collection/) { $line = qq!
!; } else { $line = qq!!; } return $line; } ############################################ # Sub rutine: Converting none standard letters to UNICODE # TMB 6/4-99 sub to_UNICODE { my ($line, $charCodingSystem) = @_; #print ("line:",$line," charCodingSystem:",$charCodingSystem,"\n"); # Replace any diacritical letters with the letter in UNICODE # The encoding of diacritical letters a using the table charcode, # and we are using the model "latin letter" + "nonscpace diacritical mark" # Replace any "&" characters $line =~ s/(.?)\&(.?)/$1&$2/g; # Remove any char(hex("FA")) from the line $pattern = "(.?)".chr(hex("FA"))."+(.?)"; $line =~ s/$pattern/$1$2/g; # Remove any char(hex("1E")) from the end of the line $pattern = "(.?)".chr(hex("1E")); $line =~ s/$pattern/$1/g; # If this is NOT the NMD or BL catalogue description collection, remove all <> if (($inFormat !~ /NMD/) && ($inFormat !~ /BL_cat_desc/)) { #print ("Her er sjekk p om det er brukt <> i innfilen \n"); $line =~ s/(.?)\<(.?)/$1<$2/g; $line =~ s/(.?)\>(.?)/$1>$2/g; } # Replace the spesific chars for this owner foreach $row (sort keys %charTable){ # $pattern = "(.?)".chr(hex($charTable{$row}))."+(.?)"; $pattern = $charTable{$row}{$charCodingSystem}; #print ("Row:",$row," Pattern:",$pattern," lenght:",length ($pattern), "\n"); if (length ($pattern) > 0) { #print ("Row:",$row,"charCodingSystem:",$charCodingSystem," Pattern:",$charTable{$row}{$charCodingSystem}, "\n"); $newencoding = $charTable{$row}{"1letter"}; if (length ($charTable{$row}{"2letter"}) > 1) { $secondLetter = $charTable{$row}{"2letter"}; $newencoding = $newencoding."\&\#x".$secondLetter.";"; #print ("newencoding:",$newencoding,"\n"); } #print ("line:",$line, "Row:",$row," Pattern:",$pattern," newencoding:", $newencoding,"\n"); $line =~ s/$pattern/$newencoding/g; } } # print ("linje:",$line,"\n"); return $line; } ############################################ # Sub rutine: Converting none standard letters to UNICODE # TMB 6/4-99 sub to_UNICODE_old { # Replace any diacritical letters with the letter in UNICODE # The encoding of diacritical letters a using the table charcode, # and we are using the model "latin letter" + "nonscpace diacritical mark" # Replace any "&" characters $line =~ s/(.?)\&(.?)/$1&$2/g; # Remove any char(hex("FA")) from the line $pattern = "(.?)".chr(hex("FA"))."+(.?)"; $line =~ s/$pattern/$1$2/g; # Remove any char(hex("1E")) from the end of the line $pattern = "(.?)".chr(hex("1E")); $line =~ s/$pattern/$1/g; # If this is NOT the NMD or BL catalogue description collection, remove all <> if (($inFormat !~ /NMD/) && ($inFormat !~ /BL_cat_desc/)) { #print ("Her er sjekk p om det er brukt <> i innfilen \n"); $line =~ s/(.?)\<(.?)/$1<$2/g; $line =~ s/(.?)\>(.?)/$1>$2/g; } # Replace the spesific chars for this owner foreach $row (sort keys %charTable){ # $pattern = "(.?)".chr(hex($charTable{$row}))."+(.?)"; $pattern = "(.?)".$charTable{$row}."+(.?)"; $newChar = chr(hex($row)); #print ("Row:",$row, "charTable{row}",$charTable{$row}," Pattern:",$pattern," newChar:", $newChar,"\n"); $line =~ s/$pattern/$1$newChar$2/g; } # print ("linje:",$line,"\n"); return $line; } ############################################ # Sub rutine: Converting local expressions to EAD expressions # TMB 7/7-99 sub translateExpressions { my ($owner, $record) = @_; # Replace the spesific local expression for this owner foreach $row (sort keys %ExprTab){ $pattern = $ExprTab{$row}{$owner}; $replaceString = $ExprTab{$row}{EAD}; if (length($pattern) > 1 ) { #print ("TranslateExpressions.pattern: ", $pattern,"\n"); #print ("TranslateExpressions.replaceString: ", $replaceString,"\n"); $record =~ s/$pattern/$replaceString/gee; } } #print ("TranslateExpressions.record: ", $record,"\n"); return $record; } ############################################ # Sub rutine: Converting local expressions to EAD expressions # TMB 7/7-99 sub translateTerm { my ($owner, $type, $term) = @_; $newTerm = $term; #print ("translateTerm.owner: ", $owner,"\n"); #print ("translateTerm.term: ", $term,"\n"); #print ("translateTerm.type: ", $type,"\n"); # Replace the spesific term for this owner foreach $row (sort keys %TermTab){ $theCode = $TermTab{$row}{$owner}; $theTerm = $TermTab{$row}{EAD}; #print ("translateTerm.row1: ", $row); $row =~ /(.+)\.\w/; $rowtype = $1; #print (" translateTerm.row2: ", $rowtype,"\n"); #print (" translateTerm.type: ", $type,"\n"); if ($rowtype eq $type) { if (length($theCode) > 0 ) { #print ("translateTerm.theCode: ", $theCode,"\n"); #print ("translateTerm.theTerm: ", $theTerm); #print ("translateTerm.rowtype: ", $rowtype,"\n"); #print ("translateTerm.term: ", $term,"\n"); if ($term eq $theCode) { $newTerm = $theTerm; #print ("translateTerm.the new term: ", $newTerm,"\n"); last; } } } } if (length($newTerm) <= 1) { print ("Did not find a translation of the term ",$term,"\n"); print ("translateTerm.owner: ", $owner,"\n"); print ("translateTerm.term: ", $term,"\n"); print ("translateTerm.type: ", $type,"\n"); } return $newTerm; } ############################################ # Sub rutine: Converting none standard role to MALVINE roles # TMB 10/8-99 sub getRole { my ($theRole, $level, $owner) = @_; # Some convertion tables %roleListRNA = ( v => 'malvine_meta1.agent.author', k => 'malvine_meta1.agent.correspondent', f => 'malvine_meta1.agent.collector', l => 'malvine_meta1.agent.present_owner', a => 'malvine_meta1.agent.addressee'); #print ("theRole:",$theRole,"\n"); if ($owner = 'OLA') { $malvineRole = $roleListRNA{$theRole}; } if ($level >= "A") { $malvineRole = $malvineRole.".".$level; } #print ("malvineRole:",$malvineRole,"\n"); return "'".$malvineRole."'"; } ############################################ # Sub rutine: Converting from local genre to MALVINE genre # TMB 10/2-99 sub getGenre { my ($theGenre, $owner) = @_; # Some convertion tables %listRNA = ( b => "Correspondence", k => "Stammstaz K\örpershaft", l => "Documents/witnesses", n => "Nachlass", ny => "Kryptonachlass", p => "Bibliography", s => "Sammlungen", w => "Manuscript"); #print("theGenre= ",$theGenre,"\n"); if ($owner = 'OLA') { $malvineGenre = $listRNA{$theGenre}; } return $malvineGenre; } ############################################ # Sub rutine: Converting from local genre to MALVINE genre # TMB 10/2-99 sub getWriting { my ($theWriting, $owner) = @_; # Some convertion tables %listGSA = ( MS => "Typesetted", ZS => "Contemporary handwriting", SS => "Later handwriting", Dr => "Print", Fak => "Facsimile", Korr => "Corrections", Schreibrname => "Name of different writer", egh => "Own handwriting"); if ($owner = 'GSA') { return $listGSA{$theWriting}; } } ############################################ # Sub rutine: Read the table with the information about the character sets used by # the local catalogues. Only read the char info for the collection in question. # TMB 6/4-99 # 3/5-99: Ignore leading comments sub makeCharConvTable { my ($owner) = @_; %charTable = (); open(CharInfo_file,"CharCode.txt")|| die("Cound not open the CharCode.txt file\n"); $lineNo = 0; # Jump over any lines which are comments (starting with #) while ($line = ) { if ($line =~ /^\#/ ) { #print ("1:",$line,); } else { # The first line which is not a comment, this should contain the column titles $line =~ s/(.+):/$2/; $row = $1; for $field ( split /\t/, $line){ $lineNo++; ($value) = split /\t/, $field; $OwnerTab[$lineNo] = $value; #print ("1:", $value,"\n"); } last; } } # Build the charinfo info table $lineNo = 0; while ($line = ) { if ($line =~ /^\#/ ) { #Jump over line starting with #, this is a comment } else { $line =~ s/(.+):\t/$1\t$2/; $rowID = $1; $lineNo = 0; #print ("3:",$rowID,":", $line,); for $field ( split /\t/, $line){ #($value) = split /\t/, $field; $value = $field; $string =chr(hex(substr($value,0,2))); # If the value is more that one char, concatinate into a string for ($i = 2; $i < length ($value); $i = $i+2) { $string = $string.chr(hex(substr($value,$i,2))); } $lineNo++; $key = $OwnerTab[$lineNo]; #print ("4:",$owner,":",$key,":", $value,":", $lineNo,"\n"); #print ("5: value: ",$value, "string :",$string, "\n"); #print ("5:",$key,":", $value,"\n"); if (length($value) >1 ){ if ($key == "2letter") { $charTable{$rowID}{$key} = $value; #print ($rowID," kol: ",$key, " verdi: ",$charTable{$rowID}{$key},"\n"); } else { $charTable{$rowID}{$key} = $string; #print ($rowID," kol: ",$key, " verdi: ",$charTable{$rowID}{$key},"\n"); } } } } } #while close(CharInfo_file); } ############################################ # Sub rutine: Read the table with the information about the collections # Build the collectionInfo table, and the collections available table "validColl" # TMB 29/3-99 sub makeCollTab { %collectionInfo = (); $validCollStr = ""; @validCollArray = (); open(COllINFO_file,"CollInfo.txt")|| die("Cound not open the CollInfo.txt file\n"); $lineNo = 0; $counter = 0; # Jump over any lines which are comments (starting with #) while ($line = ) { if ($line =~ /^\#/ ) { #print ("1:",$line,); } else { # Read the first line, this shold contain the ID of the collection availably $line =~ s/(.+):/$2/; #print ("2:",$line); $who = $1; for $field ( split /\t/, $line){ $lineNo++; ($value) = split /\t/, $field; $OwnerTab[$lineNo] = $value; #print ($lineNo,"+ ", $OwnerTab[$lineNo],"\n"); } last; } } # Build the collection info table $lineNo = 0; while ($line = ) { #print ("3:",$line,); if ($line =~ /^\#/ ) { #Jump over, this is a comment } else { $line =~ s/(.+):/$2/; $collectionID = $1; $lineNo = 0; for $field ( split /\t/, $line){ $lineNo++; ($value) = split /\t/, $field; $key = $OwnerTab[$lineNo]; $collectionInfo{$collectionID}{$key} = $value; #print ($collectionID,"-",$key,":", $value,"\n"); } if ($collectionInfo{$collectionID}{"Available"} =~ /\w/) { $validCollArray[$counter] = $collectionID; if (length($validCollStr) > 0) { $validCollStr = $validCollStr.", ".$collectionID; #print ("1", $validCollStr, "\n"); #print ("1", $counter, "\n"); $counter++ ; } else { $validCollStr = $collectionID; #print ("2", $validCollStr, "\n"); #print ("2", $counter, "\n"); $counter++ ; } } } } #while #print ("validCollStr:",$validCollStr,"\n"); #print ("validCollArray:",@validCollArray,"\n"); #print ("validCollArray:",@validCollArray[0..$#validCollArray],"\n"); close(COllINFO_file); } ############################################ # Sub rutine: Read the convertion table with the mapping between the local formats and # MALVINE metadata (with extentions), and on file with the mapping between # MALVINE metadata and EAD. # TMB 25/2-99 sub makeConTab { my ($thisCollection) = @_; %ConTab = (); # open(CONTAB_file,$innf = &StandardFile'GetFile("Choose the conversion table file", ("TEXT"))) || # die("Something went wrong in the opning of the convertion table\n"); open(CONTAB_file,"MAL_LOC.txt")|| die("Count not open the files called MAL_LOC.txt\n"); $lineNo = 0; while ($line = ) { if ($line =~ /^\#/ ) { #Jump over comments line } else { # Read the first line, this should contain the ID of the collection availably $line =~ s/(.+):(\t.+)/$2/; $rowID = $1; for $field ( split /\t/, $line){ $lineNo++; ($value) = split /\t/, $field; $OwnerTab[$lineNo] = $value; } last; } } #print ("OwnerTab: ",@OwnerTab,"\n"); # Build the convertion table # Only import rows which has value for this collection $lineNo = 0; while ($line = ) { if ($line =~ /^\#/ ) { #Jump over comments line } else { $line =~ s/(.+):(\t.+)/$2/; $rowID = $1; $lineNo = 0; for $field ( split /\t/, $line){ $lineNo++; ($value) = split /\t/, $field; $key = $OwnerTab[$lineNo]; $ConTab{$rowID}{$key} = $value; #print ($rowID,"-",$key,":","\n"); #print ($rowID,"-",$key,":", $ConTab{$rowID}{$key},"\n"); } } } #while close(CONTAB_file); } ############################################ # Sub rutine: Read the $ConTab, and convert it into a from-EAD-to-local converstion table. # Change the $1,$2.. in the EAD mapping too paranteses, and the local mapping from # parantesis to $1,$2... # TMB 4/3-99 sub makeConTab2 { %ConTab2 = (); # Build the convertion table foreach $row (sort keys %ConTab){ $EADstring = $ConTab{$row}{EAD}; if ($EADstring =~ s/qq!<\w+>(.+)\$1(.+)\$2(.+)\$3(.+)!/$1\(.+\)$2\(.+\)$3\(.+\)$4/) { } elsif ($EADstring =~ s/qq!<\w+>(.+)\$1(.+)\$2(.+)!/$1\(.+\)$2\(.+\)$3/) { } else { $EADstring =~ s/qq!<\w+>(.+)\$1(.+)!/$1\(.+\)$2/; } $ConTab2{$row}{EAD} = $EADstring; #print ($ConTab2{$row}{EAD}); foreach $column (sort keys %{$ConTab{$row}}){ if ($column !~ /EAD/) { $LocalString = $ConTab{$row}{$column}; $LocalString =~ s/(.+)\(.+\)(.?)\(.+\)(.?)\(.+\)(.?)/$1\$1$2\$2$3\$3$4/; $LocalString =~ s/(.+)\(.+\)(.?)\(.+\)(.?)/$1\$1$2\$2$3/; $LocalString =~ s/(.+)\(.+\)(.?)/$1\$1$2/; $ConTab2{$row}{$column} = "qq!$LocalString!"; #print ($row,"-",$column,":", $ConTab2{$row}{$column},"\n"); } } } } ############################################ # Sub rutine: Read the expression conversion table with the mapping between the expression # local formats and and EAD. # TMB 7/7-99 sub makeExprTab { %ExprTab = (); open(EXPRTAB_file,"exprcode.txt")|| die("Count not open the exprcode.txt file\n"); $lineNo = 0; while ($line = ) { if ($line =~ /^\#/ ) { #Jump ovr comments line } else { # Read the first line, this shold contain the ID of the collection availably $line =~ s/(.+):(.+)/$2/; $who = $1; for $field ( split /\t/, $line){ $lineNo++; ($value) = split /\t/, $field; $OwnerTab[$lineNo] = $value; } last; } } # Build the convertion table $lineNo = 0; while ($line = ) { if ($line =~ /^\#/ ) { #Jump ovr comments line } else { $line =~ s/(.+):(.+)/$2/; $who = $1; $lineNo = 0; for $field ( split /\t/, $line){ $lineNo++; ($value) = split /\t/, $field; $key = $OwnerTab[$lineNo]; $ExprTab{$who}{$key} = $value; #print ($who,"-",$key,":", $ExprTab{$who}{$key},"\n"); } } } #while close(EXPRTAB_file); } ############################################ # Sub rutine: Read the expression conversion table with the mapping between the expression # local formats and and EAD. # TMB 7/7-99 sub makeTermTab { %TermTab = (); open(TermTAB_file,"termcode.txt")|| die("Count not open the termcode.txt file\n"); $lineNo = 0; while ($line = ) { if ($line =~ /^\#/ ) { #Jump ovr comments line } else { # Read the first line, this shold contain the ID of the collection availably $line =~ s/(.+):(.+)/$2/; $who = $1; for $field ( split /\t/, $line){ $lineNo++; ($value) = split /\t/, $field; $OwnerTab[$lineNo] = $value; } last; } } # Build the convertion table $lineNo = 0; while ($line = ) { if ($line =~ /^\#/ ) { #Jump ovr comments line } else { $line =~ s/(.+):(.+)/$2/; $who = $1; $lineNo = 0; for $field ( split /\t/, $line){ $lineNo++; ($value) = split /\t/, $field; $key = $OwnerTab[$lineNo]; $TermTab{$who}{$key} = $value; #print ($who,"-",$key,":", $TermTab{$who}{$key},"\n"); } } } #while close(TermTAB_file); }