--- trunk/all2xml.pl 2003/03/15 21:33:36 40 +++ trunk/all2xml.pl 2003/06/01 13:46:42 50 @@ -19,8 +19,7 @@ my $config; use index_DBI; # there is no other, right now ;-) - -my $index = new index_DBI(); # open index +my $index; my %opts; @@ -32,7 +31,7 @@ getopts('d:m:qs', \%opts); -my $db_dir; +my $path; # this is name of database Text::Iconv->raise_error(1); # Conversion errors raise exceptions @@ -153,10 +152,10 @@ if ($filter) { no strict 'refs'; foreach my $d (&$filter($index_data)) { - $index->insert($field, $d, $db_dir); + $index->insert($field, $d, $path); } } else { - $index->insert($field, $index_data, $db_dir); + $index->insert($field, $index_data, $path); } } } @@ -214,6 +213,17 @@ my $cfg = new Config::IniFiles( -file => $config_file ); +# open index +$index = new index_DBI( + $cfg->val('global', 'dbi_dbd'), + $cfg->val('global', 'dbi_dsn'), + $cfg->val('global', 'dbi_user'), + $cfg->val('global', 'dbi_passwd') || '', + ); + +# delete [global] section to leave just databases sections +$cfg->DeleteSection('global'); + foreach my $database ($cfg->Sections) { my $isis_db = $cfg -> val($database, 'isis_db') || die "$database doesn't have 'isis_db' defined!"; @@ -252,9 +262,12 @@ $last_p = $p; } - if (my $xml = $cp2utf->convert(isis2xml($row,$add_xml))) { + my $swishpath = $path."#".int($row->{mfn}); + + if (my $xml = isis2xml($row,$add_xml)) { + $xml = $cp2utf->convert($xml); use bytes; # as opposed to chars - print "Path-Name: $path#".int($row->{mfn})."\n"; + print "Path-Name: $swishpath\n"; print "Content-Length: ".(length($xml)+1)."\n"; print "Document-Type: XML\n\n$xml\n"; }