/[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 274 by dpavlin, Sun Mar 14 11:50:29 2004 UTC revision 279 by dpavlin, Sun Mar 14 14:59:43 2004 UTC
# Line 150  sub data2xml { Line 150  sub data2xml {
150                  }                  }
151          }          }
152    
153    
154            # init variables for different types
155          sub init_visible_type($) {          sub init_visible_type($) {
156                  my $type = shift;                  my $type = shift;
157    
# Line 170  sub data2xml { Line 172  sub data2xml {
172                  return ($s,$se,$d,$i,$il);                  return ($s,$se,$d,$i,$il);
173          }          }
174    
175    
176            # convert
177            #
178            # <tag>
179            #  <delimiter>, </delimiter>
180            #  <value>200a</value>
181            # </tag>
182            #
183            # to
184            #
185            # <tag delimiter=", ">200a</tag>
186            #
187            # but without loosing spaces in delimiter (becasue
188            # new XML::Simple strips spaces in attribute values
189            # as defined in XML specification)
190            #
191            sub unroll_x($) {
192                    my $x = shift;
193    
194                    if (defined $x->{value}) {
195                            my ($v,$d) = ($x->{value}->{content}, $x->{delimiter}->{content});
196                            delete $x->{value};
197                            delete $x->{delimiter};
198                            $x->{content} = $v;
199                            $x->{delimiter} = $d;
200                    }
201                    return $x;
202            }
203    
204          # begin real work: go field by field          # begin real work: go field by field
205          foreach my $field (@sorted_tags) {          foreach my $field (@sorted_tags) {
206    
# Line 203  sub data2xml { Line 234  sub data2xml {
234    
235                  foreach my $x (@{$config->{indexer}->{$field}->{$tag}}) {                  foreach my $x (@{$config->{indexer}->{$field}->{$tag}}) {
236    
237                            $x = unroll_x($x);
238    
239                          my $format = x($x->{content});                          my $format = x($x->{content});
240                          my $delimiter = x($x->{delimiter}) || ' ';                          my $delimiter = x($x->{delimiter}) || ' ';
241    
# Line 429  sub data2xml { Line 462  sub data2xml {
462                  # now try to parse variables from configuration file                  # now try to parse variables from configuration file
463                  foreach my $x (@{$config->{indexer}->{$field}->{'config'}}) {                  foreach my $x (@{$config->{indexer}->{$field}->{'config'}}) {
464    
465                            $x = unroll_x($x);
466    
467                          my $delimiter = x($x->{delimiter}) || ' ';                          my $delimiter = x($x->{delimiter}) || ' ';
468                          my $val = $cfg->val($database, x($x->{content}));                          my $val = $cfg->val($database, x($x->{content}));
469    
# Line 613  print STDERR "reading ./import_xml/$type Line 648  print STDERR "reading ./import_xml/$type
648          my $type_base = $type;          my $type_base = $type;
649          $type_base =~ s/_.+$//g;          $type_base =~ s/_.+$//g;
650    
651          $config=XMLin("./import_xml/$type.xml", forcearray => [ $type2tag{$type_base}, 'config', 'format' ], forcecontent => 1);          $config=XMLin("./import_xml/$type.xml", ForceArray => [ $type2tag{$type_base}, 'config', 'format' ], ForceContent => 1 );
652    
653          # output current progress indicator          # output current progress indicator
654          my $last_p = 0;          my $last_p = 0;

Legend:
Removed from v.274  
changed lines
  Added in v.279

  ViewVC Help
Powered by ViewVC 1.1.26