/[webpac]/trunk/all2xml.pl
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /trunk/all2xml.pl

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 618 by dpavlin, Fri Dec 31 03:35:43 2004 UTC revision 620 by dpavlin, Sat Jan 1 18:16:21 2005 UTC
# Line 860  print STDERR "using: $type...\n"; Line 860  print STDERR "using: $type...\n";
860                  }                  }
861          } elsif ($type_base eq "marc") {          } elsif ($type_base eq "marc") {
862    
863                  require MARC;                  require MARC::File::USMARC;
864                                    
865                  $import2cp = Text::Iconv->new($config->{marc_codepage},$codepage);                  $import2cp = Text::Iconv->new($config->{marc_codepage},$codepage);
866                  my $marc_file = $cfg -> val($database, 'marc_file') || die "$database doesn't have 'marc_file' defined!";                  my $marc_file = $cfg -> val($database, 'marc_file') || die "$database doesn't have 'marc_file' defined!";
867    
868                  # optional argument is format                  # optional argument is format
869                  my $format = x($config->{marc_format}) || 'usmarc';                  warn "marc_format is no longer used!" if ($config->{marc_format});
   
870                  print STDERR "Reading MARC file '$marc_file'\n";                  print STDERR "Reading MARC file '$marc_file'\n";
871    
872                  my $marc = new MARC;                  my $marc = MARC::File::USMARC->in( $marc_file )
873                  my $nr = $marc->openmarc({                          || die "Can't open MARC file '$marc_file': ".$MARC::File::ERROR;
                                 file=>$marc_file, format=>$format  
                         }) || die "Can't open MARC file '$marc_file' with format '$format'";  
874    
875                  # read MARC file in memory                  # count records in MARC file
876                  $marc->nextmarc(-1);                  sub marc_count {
877                            my $filename = shift || die;
878                            my $file = MARC::File::USMARC->in($filename) || die $MARC::File::ERROR;
879                            my $count = 0;
880                            while ($file->skip()) {
881                                    $count++;
882                            }
883                            return $count;
884                    }
885    
886                  my $max_rec = $marc->marc_count();                  my $count = marc_count($marc_file) || warn "no records in '$marc_file'?";
887    
888                  for(my $i=1; $i<=$max_rec; $i++) {                  my $i = 0;
889    
890                          progress($i,$max_rec);                  while( my $rec = $marc->next() ) {
891    
892                          # store value for marc_sf.pm                          progress($i++,$count);
                         $main::cache->{marc_record} = $i;  
893    
894                          my $swishpath = $database."#".$i;                          my $swishpath = $database."#".$i;
895    
896                          if (my $xml = data2xml($type_base,$marc,$add_xml,$cfg,$database)) {                          if (my $xml = data2xml($type_base,$rec,$add_xml,$cfg,$database)) {
897                                  $xml = $cp2utf->convert($xml);                                  $xml = $cp2utf->convert($xml);
898                                  use bytes;      # as opposed to chars                                  use bytes;      # as opposed to chars
899                                  print "Path-Name: $swishpath\n";                                  print "Path-Name: $swishpath\n";

Legend:
Removed from v.618  
changed lines
  Added in v.620

  ViewVC Help
Powered by ViewVC 1.1.26