/[webpac]/branches/drustvene/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/drustvene/all2xml.pl

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

revision 13 by dpavlin, Sun Feb 16 22:41:37 2003 UTC revision 20 by dpavlin, Sat Feb 22 23:49:22 2003 UTC
# Line 68  sub isis2xml { Line 68  sub isis2xml {
68    
69                  my $swish_data = "";                  my $swish_data = "";
70                  my $display_data = "";                  my $display_data = "";
                 my $index_data = "";  
71    
72                  foreach my $x (@{$config->{indexer}->{$field}->{isis}}) {                  foreach my $x (@{$config->{indexer}->{$field}->{isis}}) {
73    
# Line 79  sub isis2xml { Line 78  sub isis2xml {
78                          ($s,$d,$i) = (0,0,1) if (lc($x->{type}) eq "index");                          ($s,$d,$i) = (0,0,1) if (lc($x->{type}) eq "index");
79  #print STDERR "## s: $s d: $d i: $i ## $format ##\n";    #print STDERR "## s: $s d: $d i: $i ## $format ##\n";  
80    
81                            # FIX: this is ugly, UGLY, cludge string is returned
82                            # in UTF8 encoding , but as if source charset
83                            # is ISO8859-1 and not some other. This break other
84                            # character encodings, so we convert it first
85                            # back to ISO8859-1
86                          $format = $cludge_codepage->convert($format);                          $format = $cludge_codepage->convert($format);
87    
88                          my ($swish,$display) = parse_format($format,$row);                          my ($swish,$display) = parse_format($format,$row);
89  #print STDERR "s: $swish\nd: $display\n" if ($swish);  #print STDERR "s: $swish\nd: $display\n" if ($swish);
90    
91  #print STDERR "swish: $swish<-- display: $display<--\n";  #print STDERR "swish: $swish<-- display: $display<--\n";
92                          # FIX: this is ugly, UGLY, cludge: OpenIsis return  
93                          # UTF8 encoding of strings, but as if source charset                          # filter="name" ; filter this field through
94                          # is ISO8859-1 and not some other. This breaks our                          # filter/[name].pm
95                          # isis character encoding, so we convert it first                          my $filter;
96                          # back to ISO8859-1 (which can actually be different                          if ($x->{filter}) {
97                          # encoding in isis)                                  $filter = "filter/".$x->{filter}.".pm";
98                                    require $filter;
99                          $swish_data .= $swish if ($s && $swish);                          }
100                          $display_data .= $display if ($d && $display);                          # type="swish" ; field for swish
101                          $index_data .= $display if ($i && $display);                          if ($s && $swish) {
102                                    if ($filter) {
103                                            $swish_data .= join(" ",&filter($swish));
104                                    } else {
105                                            $swish_data .= $swish if ($s && $swish);
106                                    }
107                            }
108    
109                            # type="display" ; field for display
110                            if ($d && $display) {
111                                    if ($filter) {
112                                            $display_data .= join(" ",&filter($display));
113                                    } else {
114                                            $display_data .= $display if ($s && $display);
115                                    }
116                            }
117                                            
118                            # type="index" ; insert into index
119                            if ($i && $display) {
120                                    my $index_data = $index_codepage->convert($display) || $display;
121                                    if ($filter) {
122                                            foreach my $d (&filter($index_data)) {
123                                                    $index->insert($field, $d, $db_dir);
124                                            }
125                                    } else {
126                                            $index->insert($field, $index_data, $db_dir);
127                                    }
128                            }
129                  }                  }
130    
131    
# Line 113  sub isis2xml { Line 145  sub isis2xml {
145                                          $field_name = $config->{indexer}->{$field}->{name_singular}."#-#";                                          $field_name = $config->{indexer}->{$field}->{name_singular}."#-#";
146                                  } elsif ($config->{indexer}->{$field}->{name_plural}) {                                  } elsif ($config->{indexer}->{$field}->{name_plural}) {
147                                          $field_name = $config->{indexer}->{$field}->{name_plural}."#-#";                                          $field_name = $config->{indexer}->{$field}->{name_plural}."#-#";
148                                  } else {                                  } elsif ($config->{indexer}->{$field}->{name}) {
149                                          $field_name = $config->{indexer}->{$field}->{name}."#-#";                                          $field_name = $config->{indexer}->{$field}->{name}."#-#";
150                                    } else {
151                                            print STDERR "WARNING: field '$field' doesn't have 'name' attribute!";
152                                  }                                  }
153                                  if ($field_name) {                                  if ($field_name) {
154                                          $html .= $xml_codepage->convert($field_name);                                          $html .= $xml_codepage->convert($field_name);
# Line 124  sub isis2xml { Line 158  sub isis2xml {
158                  }                  }
159                  if ($swish_data) {                  if ($swish_data) {
160                          my $i = Text::Iconv->new($config->{isis_codepage},'ISO8859-2');                          my $i = Text::Iconv->new($config->{isis_codepage},'ISO8859-2');
161                            # remove extra spaces
162                            $swish_data =~ s/ +/ /g;
163                            $swish_data =~ s/ +$//g;
164    
165                          $swish_data = $i->convert($swish_data);                          $swish_data = $i->convert($swish_data);
166                          $xml .= xmlify($field."_swish",unac_string('ISO8859-2',$swish_data));                          $xml .= xmlify($field."_swish",unac_string('ISO8859-2',$swish_data));
167                          #$swish_data = $isis_codepage->convert($swish_data)."##" || $swish_data;                          #$swish_data = $isis_codepage->convert($swish_data)."##" || $swish_data;
168                          #$xml .= xmlify($field."_swish",unac_string($config->{isis_codepage},$swish_data));                          #$xml .= xmlify($field."_swish",unac_string($config->{isis_codepage},$swish_data));
169                  }                  }
170    
                 # index  
                 if ($index_data && $index_data ne "") {  
                         $index_data = $index_codepage->convert($index_data) || $index_data;  
                         $index->insert($field, $index_data, $db_dir);  
                 }  
171    
172          }          }
173    

Legend:
Removed from v.13  
changed lines
  Added in v.20

  ViewVC Help
Powered by ViewVC 1.1.26