--- trunk/all2xml.pl 2003/02/16 22:41:37 13 +++ trunk/all2xml.pl 2003/02/23 00:00:51 21 @@ -68,7 +68,6 @@ my $swish_data = ""; my $display_data = ""; - my $index_data = ""; foreach my $x (@{$config->{indexer}->{$field}->{isis}}) { @@ -79,21 +78,54 @@ ($s,$d,$i) = (0,0,1) if (lc($x->{type}) eq "index"); #print STDERR "## s: $s d: $d i: $i ## $format ##\n"; + # FIX: this is ugly, UGLY, cludge string is returned + # in UTF8 encoding , but as if source charset + # is ISO8859-1 and not some other. This break other + # character encodings, so we convert it first + # back to ISO8859-1 $format = $cludge_codepage->convert($format); + my ($swish,$display) = parse_format($format,$row); #print STDERR "s: $swish\nd: $display\n" if ($swish); #print STDERR "swish: $swish<-- display: $display<--\n"; - # FIX: this is ugly, UGLY, cludge: OpenIsis return - # UTF8 encoding of strings, but as if source charset - # is ISO8859-1 and not some other. This breaks our - # isis character encoding, so we convert it first - # back to ISO8859-1 (which can actually be different - # encoding in isis) - - $swish_data .= $swish if ($s && $swish); - $display_data .= $display if ($d && $display); - $index_data .= $display if ($i && $display); + + # filter="name" ; filter this field through + # filter/[name].pm + my $filter; + if ($x->{filter}) { + $filter = "filter/".$x->{filter}.".pm"; + require $filter; + } + # type="swish" ; field for swish + if ($s && $swish) { + if ($filter) { + $swish_data .= join(" ",&filter($swish)); + } else { + $swish_data .= $swish if ($s && $swish); + } + } + + # type="display" ; field for display + if ($d && $display) { + if ($filter) { + $display_data .= join(" ",&filter($display)); + } else { + $display_data .= $display; + } + } + + # type="index" ; insert into index + if ($i && $display) { + my $index_data = $index_codepage->convert($display) || $display; + if ($filter) { + foreach my $d (&filter($index_data)) { + $index->insert($field, $d, $db_dir); + } + } else { + $index->insert($field, $index_data, $db_dir); + } + } } @@ -113,8 +145,10 @@ $field_name = $config->{indexer}->{$field}->{name_singular}."#-#"; } elsif ($config->{indexer}->{$field}->{name_plural}) { $field_name = $config->{indexer}->{$field}->{name_plural}."#-#"; - } else { + } elsif ($config->{indexer}->{$field}->{name}) { $field_name = $config->{indexer}->{$field}->{name}."#-#"; + } else { + print STDERR "WARNING: field '$field' doesn't have 'name' attribute!"; } if ($field_name) { $html .= $xml_codepage->convert($field_name); @@ -124,17 +158,16 @@ } if ($swish_data) { my $i = Text::Iconv->new($config->{isis_codepage},'ISO8859-2'); + # remove extra spaces + $swish_data =~ s/ +/ /g; + $swish_data =~ s/ +$//g; + $swish_data = $i->convert($swish_data); $xml .= xmlify($field."_swish",unac_string('ISO8859-2',$swish_data)); #$swish_data = $isis_codepage->convert($swish_data)."##" || $swish_data; #$xml .= xmlify($field."_swish",unac_string($config->{isis_codepage},$swish_data)); } - # index - if ($index_data && $index_data ne "") { - $index_data = $index_codepage->convert($index_data) || $index_data; - $index->insert($field, $index_data, $db_dir); - } }