/[webpac]/branches/ffzg/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 /branches/ffzg/all2xml.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 188 by dpavlin, Sat Nov 29 19:07:00 2003 UTC
# Line 116  sub data2xml { Line 116  sub data2xml {
116          delete $cache->{display_data};          delete $cache->{display_data};
117          delete $cache->{swish_data};          delete $cache->{swish_data};
118          delete $cache->{swish_exact_data};          delete $cache->{swish_exact_data};
119            delete $cache->{index_data};
120            delete $cache->{index_delimiter};
121          my @page_fields;        # names of fields          my @page_fields;        # names of fields
122    
123    
# Line 150  sub data2xml { Line 152  sub data2xml {
152                  my $swish_data = "";                  my $swish_data = "";
153                  my $swish_exact_data = "";                  my $swish_exact_data = "";
154                  my $display_data = "";                  my $display_data = "";
155                    my @index_data;
156                  my $line_delimiter;                  my $line_delimiter;
157    
158                  my ($swish,$display);                  my ($swish,$display);
# Line 162  sub data2xml { Line 165  sub data2xml {
165                  my %page_max = ();                  my %page_max = ();
166                  # default line_delimiter if using                  # default line_delimiter if using
167                  my $page_line_delimiter = $config->{indexer}->{$field}->{page_line_delimiter} || '<br/>';                  my $page_line_delimiter = $config->{indexer}->{$field}->{page_line_delimiter} || '<br/>';
168                    $cache->{index_delimiter}->{$field} = $config->{indexer}->{$field}->{index_delimiter};
169    
170                  foreach my $x (@{$config->{indexer}->{$field}->{$tag}}) {                  foreach my $x (@{$config->{indexer}->{$field}->{$tag}}) {
171    
# Line 175  sub data2xml { Line 179  sub data2xml {
179                          my ($s,$se,$d,$i,$il) = (1,0,1,0,0);                          my ($s,$se,$d,$i,$il) = (1,0,1,0,0);
180                          $s = 0 if (lc($x->{type}) eq "display");                          $s = 0 if (lc($x->{type}) eq "display");
181                          $d = 0 if (lc($x->{type}) eq "swish");                          $d = 0 if (lc($x->{type}) eq "swish");
182                          $se = 1 if (lc($x->{type}) eq "swish_exact");                          ($s,$se,$d,$i) = (0,1,0,1) if (lc($x->{type}) eq "index");
183                          ($s,$d,$i) = (0,0,1) if (lc($x->{type}) eq "index");                          ($s,$se,$d,$i) = (0,1,0,0) if (lc($x->{type}) eq "swish_exact");
184                          $il = 1 if (lc($x->{type}) =~ /^lookup/);                          ($s,$se,$d,$i,$il) = (0,1,0,0,1) if (lc($x->{type}) =~ /^lookup/);
   
185    
186                          # what will separate last line from this one?                          # what will separate last line from this one?
187                          if ($display_data && $x->{append} && $x->{append} eq "1") {                          if ($display_data && $x->{append}) {
188                                  $line_delimiter = ' ';                                  $line_delimiter = ' ';
189                          } elsif ($display_data) {                          } elsif ($display_data) {
190                                  $line_delimiter = '<br/>';                                  $line_delimiter = '<br/>';
# Line 191  sub data2xml { Line 194  sub data2xml {
194                          ($swish,$display) = (1,1);                          ($swish,$display) = (1,1);
195    
196                          # placeholder for all repeatable entries for index                          # placeholder for all repeatable entries for index
                         my @index_data;  
197    
198                          sub mkformat {                          sub mkformat {
199                                  my $x = shift || die "mkformat needs tag reference";                                  my $x = shift || die "mkformat needs tag reference";
# Line 295  sub data2xml { Line 297  sub data2xml {
297                                  }                                  }
298                                                                                                    
299                                  # type="index" ; insert into index                                  # type="index" ; insert into index
300                                    my $idisplay;
301                                  if ($i && $display) {                                  if ($i && $display) {
302                                            $idisplay = $display;
303                                          if ($filter) {                                          if ($filter) {
304                                                  no strict 'refs';                                                  no strict 'refs';
305                                                  $display = &$filter($display);                                                  $idisplay = &$filter($idisplay);
                                         }  
                                         if ($x->{append} && @index_data) {  
                                                 $index_data[$#index_data].=$display;  
                                         } else {  
                                                 push @index_data, $display;  
306                                          }                                          }
307                                            push @index_data, $idisplay if (! $iterate_by_page);
308                                  }                                  }
309    
310                                  # store fields in lookup                                  # store fields in lookup
# Line 330  sub data2xml { Line 330  sub data2xml {
330                                          sub iterate_fld($$$$$$) {                                          sub iterate_fld($$$$$$) {
331                                                  my ($cache,$what,$field,$page,$data,$append) = @_;                                                  my ($cache,$what,$field,$page,$data,$append) = @_;
332                                                  return if (!$data);                                                  return if (!$data);
333                                                  my $line_delimiter = $page_line_delimiter;  
334                                                  $line_delimiter = " " if ($append);                                                  my $ldel = $page_line_delimiter;
335                                                    $ldel = " " if ($append);
336    #print STDERR "line delimiter: ",Dumper($ldel) if ($ldel);
337                                                  if (! $cache->{$what}->{$field}->[$page]) {                                                  if (! $cache->{$what}->{$field}->[$page]) {
338                                                          $cache->{$what}->{$field}->[$page] = $data;                                                          $cache->{$what}->{$field}->[$page] = $data;
339                                                  } else {                                                  } else {
340                                                          $cache->{$what}->{$field}->[$page] .= $line_delimiter.$data;                                                          $cache->{$what}->{$field}->[$page] .= $ldel.$data;
341                                                  }                                                  }
342                                          }                                          }
343    
344                                          if ($display_data) {                                          if ($display_data) {
 print STDERR "line delimiter: ",Dumper($line_delimiter) if ($line_delimiter);  
345                                                  iterate_fld($cache,'display_data',$field,$page,$display_data,$x->{append});                                                  iterate_fld($cache,'display_data',$field,$page,$display_data,$x->{append});
346                                          }                                          }
347                                                  $display_data = "";                                                  $display_data = "";
# Line 352  print STDERR "line delimiter: ",Dumper($ Line 353  print STDERR "line delimiter: ",Dumper($
353                                                  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});
354                                                  $swish_exact_data = "";                                                  $swish_exact_data = "";
355                                          }                                          }
356    
357                                            if ($idisplay) {
358                                                    my $ldel=$page_line_delimiter;
359                                                    my @index_data;
360                                                    if ($cache->{index_data}->{$field}->[$page]) {
361    
362                                                            @index_data = @{$cache->{index_data}->{$field}->[$page]};
363                                                    }
364                                                    if ($x->{append}) {
365                                                            $index_data[$#index_data] .= $idisplay;
366                                                    } else {
367                                                            push @index_data, $idisplay;
368                                                    }
369                                                    $idisplay = "";
370                                                    @{$cache->{index_data}->{$field}->[$page]} = @index_data;
371                                            }
372                                  }                                  }
373                          }                          }
374    
375                          # fill data in index                          if (! $iterate_by_page) {
376                          foreach my $d (@index_data) {                                  my $idel = $x->{index_delimiter};
377                                  $index->insert($field, $d, $path);                                  # fill data in index
378                                    foreach my $tmp (@index_data) {
379                                            my $i = $d = $tmp;
380                                            if ($idel && $tmp =~ m/$idel/) {
381                                                    ($i,$d) = split(/$idel/,$tmp);
382                                            }
383                                            $index->insert($field, $i, $d, $path);
384                                    }
385                                    @index_data = ();
386                          }                          }
387                  }                  }
388    
# Line 436  print STDERR "line delimiter: ",Dumper($ Line 461  print STDERR "line delimiter: ",Dumper($
461                                          # That is required to produce exact match                                          # That is required to produce exact match
462                                          $xml .= xmlify($field."_swish_exact", unac_string($codepage,'xxbxx '.$swish_exact_data.' xxexx'));                                          $xml .= xmlify($field."_swish_exact", unac_string($codepage,'xxbxx '.$swish_exact_data.' xxexx'));
463                                  }                                  }
464                                    
465                                    my $idel = $cache->{index_delimiter}->{$field};
466                                    foreach my $tmp (@{$cache->{index_data}->{$field}->[$page]}) {
467                                            my $i = $tmp;
468                                            my $d = $tmp;
469                                            if ($idel && $tmp =~ m/$idel/) {
470                                                    ($i,$d) = split(/$idel/,$tmp);
471                                            }
472                                            $index->insert($field, $i, $d, $path);
473    #print STDERR "index [$idel] $field: $i --> $d [$path]\n";
474                                    }
475                          }                          }
476                    
477                  }                  }

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

  ViewVC Help
Powered by ViewVC 1.1.26