/[webpac]/trunk2/all2all.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 /trunk2/all2all.pl

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

revision 180 by dpavlin, Tue Nov 25 20:04:24 2003 UTC revision 298 by dpavlin, Fri Apr 2 23:31:25 2004 UTC
# Line 17  $|=1; Line 17  $|=1;
17    
18  my $config_file = $0;  my $config_file = $0;
19  $config_file =~ s/\.pl$/.conf/;  $config_file =~ s/\.pl$/.conf/;
20    $config_file = $ARGV[0] if (-f $ARGV[0]);
21  die "FATAL: can't find configuration file '$config_file'" if (! -e $config_file);  die "FATAL: can't find configuration file '$config_file'" if (! -e $config_file);
22    
23  my $config;  my $config;
# Line 72  my %lhash; Line 73  my %lhash;
73  # if you are tight on memory, turn this off  # if you are tight on memory, turn this off
74  my $use_lhash_cache = 1;  my $use_lhash_cache = 1;
75    
76    my $last_field_name;    # cache to prevent repeated fields
77    
78  sub data2xml {  sub data2xml {
79    
80          use xmlify;          use xmlify;
# Line 116  sub data2xml { Line 119  sub data2xml {
119          delete $cache->{display_data};          delete $cache->{display_data};
120          delete $cache->{swish_data};          delete $cache->{swish_data};
121          delete $cache->{swish_exact_data};          delete $cache->{swish_exact_data};
122            delete $cache->{index_data};
123            delete $cache->{index_delimiter};
124          my @page_fields;        # names of fields          my @page_fields;        # names of fields
125    
126    
# Line 136  sub data2xml { Line 141  sub data2xml {
141                          print STDERR "WARNING: field '$field' doesn't have 'name' attribute!";                          print STDERR "WARNING: field '$field' doesn't have 'name' attribute!";
142                  }                  }
143                  if ($field_name) {                  if ($field_name) {
144                          return x($field_name);                          if (! $last_field_name) {
145                                    $last_field_name = x($field_name);
146                                    return $last_field_name;
147                            } elsif ($field_name ne $last_field_name) {
148                                    $last_field_name = x($field_name);
149                                    return $last_field_name;
150                            }
151                  }                  }
152          }          }
153    
154    
155            # init variables for different types
156            sub init_visible_type($) {
157                    my $type = shift;
158    
159                    # swish, swish_exact, display, index, index_lookup
160                    # swish and display defaults
161                    my ($s,$se,$d,$i,$il) = (1,0,1,0,0);
162                    if (lc($type) eq "display") {
163                            $s = 0;
164                    } elsif (lc($type) eq "swish") {
165                            $d = 0;
166                    } elsif (lc($type) eq "index") {
167                            ($s,$se,$d,$i) = (0,1,0,1);
168                    } elsif (lc($type) eq "swish_exact") {
169                            ($s,$se,$d,$i) = (0,1,0,0);
170                    } elsif (lc($type) =~ /^lookup/) {
171                            ($s,$se,$d,$i,$il) = (0,1,0,0,1);
172                    }
173                    return ($s,$se,$d,$i,$il);
174            }
175    
176    
177            # convert
178            #
179            # <tag>
180            #  <delimiter>, </delimiter>
181            #  <value>200a</value>
182            # </tag>
183            #
184            # to
185            #
186            # <tag delimiter=", ">200a</tag>
187            #
188            # but without loosing spaces in delimiter (becasue
189            # new XML::Simple strips spaces in attribute values
190            # as defined in XML specification)
191            #
192            sub unroll_x($) {
193                    my $x = shift;
194    
195                    if (defined $x->{value}) {
196                            my ($v,$d) = ($x->{value}->{content}, $x->{delimiter}->{content});
197                            delete $x->{value};
198                            delete $x->{delimiter};
199                            $x->{content} = $v;
200                            $x->{delimiter} = $d;
201                    }
202                    return $x;
203            }
204    
205          # begin real work: go field by field          # begin real work: go field by field
206          foreach my $field (@sorted_tags) {          foreach my $field (@sorted_tags) {
207    
# Line 150  sub data2xml { Line 211  sub data2xml {
211                  my $swish_data = "";                  my $swish_data = "";
212                  my $swish_exact_data = "";                  my $swish_exact_data = "";
213                  my $display_data = "";                  my $display_data = "";
214                    my @index_data;
215                  my $line_delimiter;                  my $line_delimiter;
216    
217                  my ($swish,$display);                  my ($swish,$display);
# Line 162  sub data2xml { Line 224  sub data2xml {
224                  my %page_max = ();                  my %page_max = ();
225                  # default line_delimiter if using                  # default line_delimiter if using
226                  my $page_line_delimiter = $config->{indexer}->{$field}->{page_line_delimiter} || '<br/>';                  my $page_line_delimiter = $config->{indexer}->{$field}->{page_line_delimiter} || '<br/>';
227                    $cache->{index_delimiter}->{$field} = $config->{indexer}->{$field}->{index_delimiter};
228    
229                    my $format_name = $config->{indexer}->{$field}->{format_name};
230                    my $format_delimiter = $config->{indexer}->{$field}->{format_delimiter};
231                    if ($format_name && $format_delimiter) {
232                            $cache->{format}->{$field}->{format_name} = $format_name;
233                            $cache->{format}->{$field}->{format_delimiter} = $format_delimiter;
234                    }
235    
236                  foreach my $x (@{$config->{indexer}->{$field}->{$tag}}) {                  foreach my $x (@{$config->{indexer}->{$field}->{$tag}}) {
237    
238                            $x = unroll_x($x);
239    
240                          my $format = x($x->{content});                          my $format = x($x->{content});
241                          my $delimiter = x($x->{delimiter}) || ' ';                          my $delimiter = x($x->{delimiter}) || ' ';
242    
243                          my $repeat_off = 0;     # init repeatable offset                          my $repeat_off = 0;     # init repeatable offset
244    
245                          # swish, swish_exact, display, index, index_lookup                          my ($s,$se,$d,$i,$il) = init_visible_type($x->{type});
                         # swish and display defaults  
                         my ($s,$se,$d,$i,$il) = (1,0,1,0,0);  
                         $s = 0 if (lc($x->{type}) eq "display");  
                         $d = 0 if (lc($x->{type}) eq "swish");  
                         $se = 1 if (lc($x->{type}) eq "swish_exact");  
                         ($s,$d,$i) = (0,0,1) if (lc($x->{type}) eq "index");  
                         $il = 1 if (lc($x->{type}) =~ /^lookup/);  
   
246    
247                          # what will separate last line from this one?                          # what will separate last line from this one?
248                          if ($display_data && $x->{append} && $x->{append} eq "1") {                          if ($display_data && $x->{append}) {
249                                  $line_delimiter = ' ';                                  $line_delimiter = $delimiter;
250                          } elsif ($display_data) {                          } elsif ($display_data) {
251                                  $line_delimiter = '<br/>';                                  $line_delimiter = '<br/>';
252                          }                          }
# Line 191  sub data2xml { Line 255  sub data2xml {
255                          ($swish,$display) = (1,1);                          ($swish,$display) = (1,1);
256    
257                          # placeholder for all repeatable entries for index                          # placeholder for all repeatable entries for index
                         my @index_data;  
258    
259                          sub mkformat {                          sub mkformat($$) {
260                                  my $x = shift || die "mkformat needs tag reference";                                  my $x = shift || die "mkformat needs tag reference";
261                                  my $data = shift || return;                                  my $data = shift || return;
262                                  my $format_name = x($x->{format_name}) || return $data;                                  my $format_name = x($x->{format_name}) || return $data;
# Line 211  sub data2xml { Line 274  sub data2xml {
274                                          if (($#data+1) == $nr) {                                          if (($#data+1) == $nr) {
275                                                  return sprintf($fmt,@data);                                                  return sprintf($fmt,@data);
276                                          } else {                                          } else {
277                                                  print STDERR "mkformat: [$data] can't be split on [$format_delimiter] to $nr fields!\n";                                                  #print STDERR "mkformat: [$data] can't be split on [$format_delimiter] to $nr fields!\n";
278                                                  return $data;                                                  return $data;
279                                          }                                          }
280                                  } else {                                  } else {
# Line 240  sub data2xml { Line 303  sub data2xml {
303                                                                  $display = $new_display;                                                                  $display = $new_display;
304                                                                  $cache->{lhash}->{$display} = $new_display;                                                                  $cache->{lhash}->{$display} = $new_display;
305                                                          } else {                                                          } else {
306                                                                  print STDERR "WARNING: lookup for '$display' didn't find anything.\n";  #                                                               print STDERR "WARNING: lookup for '$display' didn't find anything.\n";
307                                                                  $display = "";                                                                  $display = "";
308                                                                  $cache->{lhash}->{$display} = $null;                                                                  $cache->{lhash}->{$display} = $null;
309                                                          }                                                          }
# Line 261  sub data2xml { Line 324  sub data2xml {
324                                  }                                  }
325                                  # type="swish" ; field for swish                                  # type="swish" ; field for swish
326                                  if ($swish) {                                  if ($swish) {
327                                            my $tmp = $swish;
328                                          if ($filter && ($s || $se)) {                                          if ($filter && ($s || $se)) {
329                                                  no strict 'refs';                                                  no strict 'refs';
330                                                  my $tmp = join(" ",&$filter($swish)) if ($s || $se);                                                  $tmp = join(" ",&$filter($tmp)) if ($s || $se);
                                                 $swish_data .= $tmp if ($s);  
                                                 $swish_exact_data .= $tmp if ($se);  
   
                                         } else {  
                                                 $swish_data .= $swish if ($s);  
                                                 $swish_exact_data .= $swish if ($se);  
331                                          }                                          }
332    
333                                            $swish_data .= $tmp if ($s && $tmp);
334                                            $swish_exact_data .= "xxbxx $tmp xxexx " if ($tmp && $tmp ne "" && $se);
335                                  }                                  }
336    
337                                  # type="display" ; field for display                                  # type="display" ; field for display
338                                  if ($d && $display) {                                  if ($d && $display) {
339                                            my $ldel = $delimiter;
340                                          if ($line_delimiter && $display_data) {                                          if ($line_delimiter && $display_data) {
341                                                  $display_data .= $line_delimiter;                                                  $ldel = $line_delimiter;
342                                          }                                          }
343                                          if ($filter) {                                          if ($filter) {
344                                                  no strict 'refs';                                                  no strict 'refs';
345                                                  if ($display_data) {                                                  my @arr;
346                                                          $display_data .= $delimiter.join($delimiter,mkformat($x,&$filter($display)));                                                  foreach my $tmp (&$filter($display)) {
347                                                  } else {                                                          my $tmp2 = mkformat($x,$tmp);
348                                                          $display_data = join($delimiter,mkformat($x,&$filter($display)));                                                          push @arr,$tmp2 if ($tmp2);
349                                                  }                                                  }
350                                                    $display_data .= $ldel if ($display_data && @arr);
351                                                    $display_data .= join($delimiter,@arr);
352                                          } else {                                          } else {
353                                                  if ($display_data) {                                                  $display_data .= $ldel if ($display_data);
354                                                          $display_data .= $delimiter.mkformat($x,$display);                                                  my $tmp = mkformat($x,$display);
355                                                  } else {                                                  $display_data .= $tmp if ($tmp);
                                                         $display_data = mkformat($x,$display);  
                                                 }  
356                                          }                                          }
357                                  }                                  }
358                                                                                                    
359                                  # type="index" ; insert into index                                  # type="index" ; insert into index
360                                    my $idisplay;
361                                  if ($i && $display) {                                  if ($i && $display) {
362                                            $idisplay = $display;
363                                          if ($filter) {                                          if ($filter) {
364                                                  no strict 'refs';                                                  no strict 'refs';
365                                                  $display = &$filter($display);                                                  $idisplay = &$filter($idisplay);
                                         }  
                                         if ($x->{append} && @index_data) {  
                                                 $index_data[$#index_data].=$display;  
                                         } else {  
                                                 push @index_data, $display;  
366                                          }                                          }
367                                            push @index_data, $idisplay if ($idisplay && !$iterate_by_page);
368                                  }                                  }
369    
370                                  # store fields in lookup                                  # store fields in lookup
# Line 313  sub data2xml { Line 373  sub data2xml {
373                                                  if ($lookup_key) {                                                  if ($lookup_key) {
374                                                          print STDERR "WARNING: try to redefine lookup_key (keys shouldn't be repeatable fields!)";                                                          print STDERR "WARNING: try to redefine lookup_key (keys shouldn't be repeatable fields!)";
375                                                  } else {                                                  } else {
376                                                          $lookup_key = $display;                                                          if ($filter) {
377                                                                    no strict 'refs';
378                                                                    $lookup_key = &$filter($display);
379                                                            } else {
380                                                                    $lookup_key = $display;
381                                                            }
382                                                  }                                                  }
383                                          } elsif (lc($x->{type}) eq "lookup_val") {                                          } elsif (lc($x->{type}) eq "lookup_val") {
384                                                  if ($lookup_key) {                                                  if ($lookup_key) {
385                                                          $lhash{$lookup_key} = $display;                                                          if ($filter) {
386                                                                    no strict 'refs';
387                                                                    $lhash{$lookup_key} = &$filter($display);
388                                                            } else {
389                                                                    $lhash{$lookup_key} = $display;
390                                                            }
391                                                  } else {                                                  } else {
392                                                          print STDERR "WARNING: no lookup_key defined for  '$display'?";                                                          print STDERR "WARNING: no lookup_key defined for  '$display'?";
393                                                  }                                                  }
# Line 330  sub data2xml { Line 400  sub data2xml {
400                                          sub iterate_fld($$$$$$) {                                          sub iterate_fld($$$$$$) {
401                                                  my ($cache,$what,$field,$page,$data,$append) = @_;                                                  my ($cache,$what,$field,$page,$data,$append) = @_;
402                                                  return if (!$data);                                                  return if (!$data);
403                                                  my $line_delimiter = $page_line_delimiter;  
404                                                  $line_delimiter = " " if ($append);                                                  my $ldel = $page_line_delimiter;
405                                                    $ldel = " " if ($append);
406    #print STDERR "line delimiter: ",Dumper($ldel) if ($ldel);
407                                                  if (! $cache->{$what}->{$field}->[$page]) {                                                  if (! $cache->{$what}->{$field}->[$page]) {
408                                                          $cache->{$what}->{$field}->[$page] = $data;                                                          $cache->{$what}->{$field}->[$page] = $data;
409                                                  } else {                                                  } else {
410                                                          $cache->{$what}->{$field}->[$page] .= $line_delimiter.$data;                                                          $cache->{$what}->{$field}->[$page] .= $ldel.$data;
411                                                  }                                                  }
412                                          }                                          }
413    
414                                          if ($display_data) {                                          if ($display_data) {
 print STDERR "line delimiter: ",Dumper($line_delimiter) if ($line_delimiter);  
415                                                  iterate_fld($cache,'display_data',$field,$page,$display_data,$x->{append});                                                  iterate_fld($cache,'display_data',$field,$page,$display_data,$x->{append});
416                                          }                                          }
417                                                  $display_data = "";                                                  $display_data = "";
# Line 352  print STDERR "line delimiter: ",Dumper($ Line 423  print STDERR "line delimiter: ",Dumper($
423                                                  iterate_fld($cache,'swish_exact_data',$field,$page,$swish_exact_data,$x->{append});                                                  iterate_fld($cache,'swish_exact_data',$field,$page,$swish_exact_data,$x->{append});
424                                                  $swish_exact_data = "";                                                  $swish_exact_data = "";
425                                          }                                          }
426    
427                                            if ($idisplay) {
428                                                    my $ldel=$page_line_delimiter;
429                                                    my @index_data;
430                                                    if ($cache->{index_data}->{$field}->[$page]) {
431    
432                                                            @index_data = @{$cache->{index_data}->{$field}->[$page]};
433                                                    }
434                                                    if ($x->{append}) {
435                                                            if (@index_data) {
436                                                                    $index_data[$#index_data] .= $idisplay;
437                                                            } else {
438                                                                    push @index_data, $idisplay;
439                                                            }
440                                                    } else {
441                                                            push @index_data, $idisplay;
442                                                    }
443                                                    $idisplay = "";
444                                                    @{$cache->{index_data}->{$field}->[$page]} = @index_data;
445                                            }
446                                  }                                  }
447                          }                          }
448    
449                          # fill data in index                          if (! $iterate_by_page) {
450                          foreach my $d (@index_data) {                                  my $idel = $x->{index_delimiter};
451                                  $index->insert($field, $d, $path);                                  # fill data in index
452                                    foreach my $tmp (@index_data) {
453                                            my $i = $d = $tmp;
454                                            if ($idel && $tmp =~ m/$idel/) {
455                                                    ($i,$d) = split(/$idel/,$tmp);
456                                            }
457                                            $index->insert($field, $i, $d, $path);
458                                    }
459                                    @index_data = ();
460                          }                          }
461                  }                  }
462    
463                  # now try to parse variables from configuration file                  # now try to parse variables from configuration file
464                  foreach my $x (@{$config->{indexer}->{$field}->{'config'}}) {                  foreach my $x (@{$config->{indexer}->{$field}->{'config'}}) {
465    
466                            $x = unroll_x($x);
467    
468                          my $delimiter = x($x->{delimiter}) || ' ';                          my $delimiter = x($x->{delimiter}) || ' ';
469                          my $val = $cfg->val($database, x($x->{content}));                          my $val = $cfg->val($database, x($x->{content}));
470    
471                          my ($s,$d,$i) = (1,1,0);        # swish, display default                          # FIXME index_lookup is not supported!
472                          $s = 0 if (lc($x->{type}) eq "display");                          my ($s,$se,$d,$i,$il) = init_visible_type($x->{type});
                         $d = 0 if (lc($x->{type}) eq "swish");  
                         # no support for swish exact in config.  
                         # IMHO, it's useless  
                         ($s,$d,$i) = (0,0,1) if (lc($x->{type}) eq "index");  
473    
474                          if ($val) {                          if ($val) {
475                                  $display_data .= $delimiter.$val if ($d);                                  $display_data .= $delimiter.$val if ($d);
476                                  $swish_data .= $val if ($s);                                  $swish_data .= " ".$val if ($s);
477                                  $index->insert($field, $val, $path) if ($i);                                  $index->insert($field, $val, $path) if ($i);
478                          }                          }
479    
# Line 405  print STDERR "line delimiter: ",Dumper($ Line 502  print STDERR "line delimiter: ",Dumper($
502  #print STDERR "field '$field' iterate over ",($nr_pages || 0)," pages...\n";  #print STDERR "field '$field' iterate over ",($nr_pages || 0)," pages...\n";
503  #print STDERR Dumper($cache->{display_data});  #print STDERR Dumper($cache->{display_data});
504                          for (my $page=0; $page <= $nr_pages; $page++) {                          for (my $page=0; $page <= $nr_pages; $page++) {
505                                    my $display_data;
506                                  my $display_data = $cache->{display_data}->{$field}->[$page];                                  if ($cache->{format}->{$field}) {
507                                            my $tmp = mkformat($cache->{format}->{$field},$cache->{display_data}->{$field}->[$page]);
508                                            $display_data=$tmp if ($tmp);
509                                    } else {
510                                            $display_data = $cache->{display_data}->{$field}->[$page];
511                                    }
512                                  if ($display_data) { # default                                  if ($display_data) { # default
513                                          if ($field eq "headline") {                                          if ($field eq "headline") {
514                                                  $xml .= xmlify("headline", $display_data);                                                  $xml .= xmlify("headline", $display_data);
# Line 434  print STDERR "line delimiter: ",Dumper($ Line 536  print STDERR "line delimiter: ",Dumper($
536    
537                                          # add delimiters before and after word.                                          # add delimiters before and after word.
538                                          # That is required to produce exact match                                          # That is required to produce exact match
539                                          $xml .= xmlify($field."_swish_exact", unac_string($codepage,'xxbxx '.$swish_exact_data.' xxexx'));                                          $xml .= xmlify($field."_swish_exact", unac_string($codepage,$swish_exact_data));
540                                    }
541                                    
542                                    my $idel = $cache->{index_delimiter}->{$field};
543                                    foreach my $tmp (@{$cache->{index_data}->{$field}->[$page]}) {
544                                            my $i = $tmp;
545                                            my $d = $tmp;
546                                            if ($idel && $tmp =~ m/$idel/) {
547                                                    ($i,$d) = split(/$idel/,$tmp);
548                                            }
549                                            $index->insert($field, $i, $d, $path);
550    #print STDERR "index [$idel] $field: $i --> $d [$path]\n";
551                                  }                                  }
552                          }                          }
553                    
# Line 465  print STDERR "line delimiter: ",Dumper($ Line 578  print STDERR "line delimiter: ",Dumper($
578    
579                                  # add delimiters before and after word.                                  # add delimiters before and after word.
580                                  # That is required to produce exact match                                  # That is required to produce exact match
581                                  $xml .= xmlify($field."_swish_exact", unac_string($codepage,'xxbxx '.$swish_exact_data.' xxexx'));                                  $xml .= xmlify($field."_swish_exact", unac_string($codepage,$swish_exact_data));
582                          }                          }
583                  }                  }
584          }          }
# Line 518  foreach my $database ($cfg->Sections) { Line 631  foreach my $database ($cfg->Sections) {
631                  #tie %lhash, 'GDBM_File', $lookup_file, &GDBM_NEWDB, 0644;                  #tie %lhash, 'GDBM_File', $lookup_file, &GDBM_NEWDB, 0644;
632                  tie %lhash, 'TDB_File', $lookup_file, TDB_CLEAR_IF_FIRST, O_RDWR, 0644;                  tie %lhash, 'TDB_File', $lookup_file, TDB_CLEAR_IF_FIRST, O_RDWR, 0644;
633                  print STDERR "creating lookup file '$lookup_file'\n";                  print STDERR "creating lookup file '$lookup_file'\n";
634                    # delete memory cache for lookup file
635                    delete $cache->{lhash};
636          }          }
637    
638          # open existing lookup file          # open existing lookup file
# Line 534  print STDERR "reading ./import_xml/$type Line 649  print STDERR "reading ./import_xml/$type
649          my $type_base = $type;          my $type_base = $type;
650          $type_base =~ s/_.+$//g;          $type_base =~ s/_.+$//g;
651    
652          $config=XMLin("./import_xml/$type.xml", forcearray => [ $type2tag{$type_base}, 'config', 'format' ], forcecontent => 1);          $config=XMLin("./import_xml/$type.xml", ForceArray => [ $type2tag{$type_base}, 'config', 'format' ], ForceContent => 1 );
653    
654          # output current progress indicator          # output current progress indicator
655          my $last_p = 0;          my $last_p = 0;
# Line 654  print STDERR "using: $type...\n"; Line 769  print STDERR "using: $type...\n";
769                  print STDERR "\n";                  print STDERR "\n";
770    
771          } elsif ($type_base eq "excel") {          } elsif ($type_base eq "excel") {
772                  use Spreadsheet::ParseExcel;                  require Spreadsheet::ParseExcel;
773                  use Spreadsheet::ParseExcel::Utility qw(int2col);                  require Spreadsheet::ParseExcel::Utility;
774                    import Spreadsheet::ParseExcel::Utility qw(int2col);
775                                    
776                  $import2cp = Text::Iconv->new($config->{excel_codepage},$codepage);                  $import2cp = Text::Iconv->new($config->{excel_codepage},$codepage);
777                  my $excel_file = $cfg -> val($database, 'excel_file') || die "$database doesn't have 'excel_file' defined!";                  my $excel_file = $cfg -> val($database, 'excel_file') || die "$database doesn't have 'excel_file' defined!";
# Line 709  print STDERR "using: $type...\n"; Line 825  print STDERR "using: $type...\n";
825                  }                  }
826          } elsif ($type_base eq "marc") {          } elsif ($type_base eq "marc") {
827    
828                  use MARC;                  require MARC;
829                                    
830                  $import2cp = Text::Iconv->new($config->{marc_codepage},$codepage);                  $import2cp = Text::Iconv->new($config->{marc_codepage},$codepage);
831                  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!";
832    
833                  # optional argument is format                  # optional argument is format
834                  my $format = x($config->{format}) || 'usmarc';                  my $format = x($config->{marc_format}) || 'usmarc';
835    
836                  print STDERR "Reading MARC file '$marc_file'\n";                  print STDERR "Reading MARC file '$marc_file'\n";
837    
838                  my $marc = new MARC;                  my $marc = new MARC;
839                  my $nr = $marc->openmarc({                  my $nr = $marc->openmarc({
840                                  file=>$marc_file, format=>$format                                  file=>$marc_file, format=>$format
841                          }) || die "Can't open MARC file '$marc_file'";                          }) || die "Can't open MARC file '$marc_file' with format '$format'";
842    
843                    # read MARC file in memory
844                    $marc->nextmarc(-1);
845    
846                  my $i=0;        # record nr.                  my $max_rec = $marc->marc_count();
847    
848                  my $rec;                  for(my $i=1; $i<=$max_rec; $i++) {
849    
850                  while ($marc->nextmarc(1)) {                          progress($i,$max_rec);
851    
852                          # XXX                          # store value for marc_sf.pm
853                          fakeprogress($i++);                          $main::cache->{marc_record} = $i;
854    
855                          my $swishpath = $database."#".$i;                          my $swishpath = $database."#".$i;
856    
# Line 743  print STDERR "using: $type...\n"; Line 862  print STDERR "using: $type...\n";
862                                  print "Document-Type: XML\n\n$xml\n";                                  print "Document-Type: XML\n\n$xml\n";
863                          }                          }
864                  }                  }
865    
866                    print STDERR "\n";
867    
868          } elsif ($type_base eq "feed") {          } elsif ($type_base eq "feed") {
869    
870                  $import2cp = Text::Iconv->new($config->{feed_codepage},$codepage);                  $import2cp = Text::Iconv->new($config->{feed_codepage},$codepage);
# Line 797  __END__ Line 919  __END__
919    
920  all2xml.pl - read various file formats and dump XML for SWISH-E  all2xml.pl - read various file formats and dump XML for SWISH-E
921    
922    =head1 SYNOPSYS
923    
924     $ all2xml.pl [test.conf]
925    
926  =head1 DESCRIPTION  =head1 DESCRIPTION
927    
928  This command will read ISIS data file using OpenIsis perl module, MARC  This command will read ISIS data file using OpenIsis perl module, MARC
# Line 805  create one XML file for usage with I<SWI Line 931  create one XML file for usage with I<SWI
931  this script B<isn't general xml generator> from isis files (isis allready  this script B<isn't general xml generator> from isis files (isis allready
932  has something like that). Output of this script is tailor-made for SWISH-E.  has something like that). Output of this script is tailor-made for SWISH-E.
933    
934    If no configuration file is specified, it will use default one called
935    C<all2xml.conf>.
936    
937  =head1 BUGS  =head1 BUGS
938    
939  Documentation is really lacking. However, in true Open Source spirit, source  Documentation is really lacking. However, in true Open Source spirit, source

Legend:
Removed from v.180  
changed lines
  Added in v.298

  ViewVC Help
Powered by ViewVC 1.1.26