--- branches/humanistika/all2xml.pl 2004/03/14 19:43:51 285
+++ branches/humanistika/all2xml.pl 2004/03/14 19:44:57 286
@@ -150,6 +150,8 @@
}
}
+
+ # init variables for different types
sub init_visible_type($) {
my $type = shift;
@@ -170,6 +172,35 @@
return ($s,$se,$d,$i,$il);
}
+
+ # convert
+ #
+ #
+ # ,
+ # 200a
+ #
+ #
+ # to
+ #
+ # 200a
+ #
+ # but without loosing spaces in delimiter (becasue
+ # new XML::Simple strips spaces in attribute values
+ # as defined in XML specification)
+ #
+ sub unroll_x($) {
+ my $x = shift;
+
+ if (defined $x->{value}) {
+ my ($v,$d) = ($x->{value}->{content}, $x->{delimiter}->{content});
+ delete $x->{value};
+ delete $x->{delimiter};
+ $x->{content} = $v;
+ $x->{delimiter} = $d;
+ }
+ return $x;
+ }
+
# begin real work: go field by field
foreach my $field (@sorted_tags) {
@@ -203,6 +234,8 @@
foreach my $x (@{$config->{indexer}->{$field}->{$tag}}) {
+ $x = unroll_x($x);
+
my $format = x($x->{content});
my $delimiter = x($x->{delimiter}) || ' ';
@@ -429,6 +462,8 @@
# now try to parse variables from configuration file
foreach my $x (@{$config->{indexer}->{$field}->{'config'}}) {
+ $x = unroll_x($x);
+
my $delimiter = x($x->{delimiter}) || ' ';
my $val = $cfg->val($database, x($x->{content}));
@@ -613,7 +648,7 @@
my $type_base = $type;
$type_base =~ s/_.+$//g;
- $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 );
# output current progress indicator
my $last_p = 0;