/[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 42 by dpavlin, Sat Mar 15 21:48:48 2003 UTC revision 50 by dpavlin, Sun Jun 1 13:46:42 2003 UTC
# Line 19  die "FATAL: can't find configuration fil Line 19  die "FATAL: can't find configuration fil
19  my $config;  my $config;
20    
21  use index_DBI;  # there is no other, right now ;-)  use index_DBI;  # there is no other, right now ;-)
22    my $index;
 my $index = new index_DBI();    # open index  
23    
24  my %opts;  my %opts;
25    
# Line 32  my %opts; Line 31  my %opts;
31    
32  getopts('d:m:qs', \%opts);  getopts('d:m:qs', \%opts);
33    
34  my $db_dir;  my $path;       # this is name of database
35    
36  Text::Iconv->raise_error(1);     # Conversion errors raise exceptions  Text::Iconv->raise_error(1);     # Conversion errors raise exceptions
37    
# Line 124  sub isis2xml { Line 123  sub isis2xml {
123                                          if ($filter) {                                          if ($filter) {
124                                                  no strict 'refs';                                                  no strict 'refs';
125                                                  $swish_data .= join(" ",&$filter($swish));                                                  $swish_data .= join(" ",&$filter($swish));
 print STDERR "#### $swish_data\n";  
126                                          } else {                                          } else {
127                                                  $swish_data .= $swish;                                                  $swish_data .= $swish;
128                                          }                                          }
# Line 154  print STDERR "#### $swish_data\n"; Line 152  print STDERR "#### $swish_data\n";
152                                          if ($filter) {                                          if ($filter) {
153                                                  no strict 'refs';                                                  no strict 'refs';
154                                                  foreach my $d (&$filter($index_data)) {                                                  foreach my $d (&$filter($index_data)) {
155                                                          $index->insert($field, $d, $db_dir);                                                          $index->insert($field, $d, $path);
156                                                  }                                                  }
157                                          } else {                                          } else {
158                                                  $index->insert($field, $index_data, $db_dir);                                                  $index->insert($field, $index_data, $path);
159                                          }                                          }
160                                  }                                  }
161                          }                          }
# Line 215  print STDERR "#### $swish_data\n"; Line 213  print STDERR "#### $swish_data\n";
213    
214  my $cfg = new Config::IniFiles( -file => $config_file );  my $cfg = new Config::IniFiles( -file => $config_file );
215    
216    # open index
217    $index = new index_DBI(
218                    $cfg->val('global', 'dbi_dbd'),
219                    $cfg->val('global', 'dbi_dsn'),
220                    $cfg->val('global', 'dbi_user'),
221                    $cfg->val('global', 'dbi_passwd') || '',
222            );
223    
224    # delete [global] section to leave just databases sections
225    $cfg->DeleteSection('global');
226    
227  foreach my $database ($cfg->Sections) {  foreach my $database ($cfg->Sections) {
228    
229          my $isis_db = $cfg -> val($database, 'isis_db') || die "$database doesn't have 'isis_db' defined!";          my $isis_db = $cfg -> val($database, 'isis_db') || die "$database doesn't have 'isis_db' defined!";
# Line 253  foreach my $database ($cfg->Sections) { Line 262  foreach my $database ($cfg->Sections) {
262                                  $last_p = $p;                                  $last_p = $p;
263                          }                          }
264    
265                          if (my $xml = $cp2utf->convert(isis2xml($row,$add_xml))) {                          my $swishpath = $path."#".int($row->{mfn});
266    
267                            if (my $xml = isis2xml($row,$add_xml)) {
268                                    $xml = $cp2utf->convert($xml);
269                                  use bytes;      # as opposed to chars                                  use bytes;      # as opposed to chars
270                                  print "Path-Name: $path#".int($row->{mfn})."\n";                                  print "Path-Name: $swishpath\n";
271                                  print "Content-Length: ".(length($xml)+1)."\n";                                  print "Content-Length: ".(length($xml)+1)."\n";
272                                  print "Document-Type: XML\n\n$xml\n";                                  print "Document-Type: XML\n\n$xml\n";
273                          }                          }

Legend:
Removed from v.42  
changed lines
  Added in v.50

  ViewVC Help
Powered by ViewVC 1.1.26