17 |
|
|
18 |
my $config_file = $0; |
my $config_file = $0; |
19 |
$config_file =~ s/\.pl$/.conf/; |
$config_file =~ s/\.pl$/.conf/; |
20 |
|
$config_file = $ARGV[0] if (-f $ARGV[0]); |
21 |
die "FATAL: can't find configuration file '$config_file'" if (! -e $config_file); |
die "FATAL: can't find configuration file '$config_file'" if (! -e $config_file); |
22 |
|
|
23 |
my $config; |
my $config; |
151 |
} |
} |
152 |
} |
} |
153 |
|
|
154 |
|
|
155 |
|
# init variables for different types |
156 |
sub init_visible_type($) { |
sub init_visible_type($) { |
157 |
my $type = shift; |
my $type = shift; |
158 |
|
|
173 |
return ($s,$se,$d,$i,$il); |
return ($s,$se,$d,$i,$il); |
174 |
} |
} |
175 |
|
|
176 |
|
|
177 |
|
# convert |
178 |
|
# |
179 |
|
# <tag> |
180 |
|
# <delimiter>, </delimiter> |
181 |
|
# <value>200a</value> |
182 |
|
# </tag> |
183 |
|
# |
184 |
|
# to |
185 |
|
# |
186 |
|
# <tag delimiter=", ">200a</tag> |
187 |
|
# |
188 |
|
# but without loosing spaces in delimiter (becasue |
189 |
|
# new XML::Simple strips spaces in attribute values |
190 |
|
# as defined in XML specification) |
191 |
|
# |
192 |
|
sub unroll_x($) { |
193 |
|
my $x = shift; |
194 |
|
|
195 |
|
if (defined $x->{value}) { |
196 |
|
my ($v,$d) = ($x->{value}->{content}, $x->{delimiter}->{content}); |
197 |
|
delete $x->{value}; |
198 |
|
delete $x->{delimiter}; |
199 |
|
$x->{content} = $v; |
200 |
|
$x->{delimiter} = $d; |
201 |
|
} |
202 |
|
return $x; |
203 |
|
} |
204 |
|
|
205 |
# begin real work: go field by field |
# begin real work: go field by field |
206 |
foreach my $field (@sorted_tags) { |
foreach my $field (@sorted_tags) { |
207 |
|
|
235 |
|
|
236 |
foreach my $x (@{$config->{indexer}->{$field}->{$tag}}) { |
foreach my $x (@{$config->{indexer}->{$field}->{$tag}}) { |
237 |
|
|
238 |
|
$x = unroll_x($x); |
239 |
|
|
240 |
my $format = x($x->{content}); |
my $format = x($x->{content}); |
241 |
my $delimiter = x($x->{delimiter}) || ' '; |
my $delimiter = x($x->{delimiter}) || ' '; |
242 |
|
|
246 |
|
|
247 |
# what will separate last line from this one? |
# what will separate last line from this one? |
248 |
if ($display_data && $x->{append}) { |
if ($display_data && $x->{append}) { |
249 |
$line_delimiter = ' '; |
$line_delimiter = $delimiter; |
250 |
} elsif ($display_data) { |
} elsif ($display_data) { |
251 |
$line_delimiter = '<br/>'; |
$line_delimiter = '<br/>'; |
252 |
} |
} |
463 |
# now try to parse variables from configuration file |
# now try to parse variables from configuration file |
464 |
foreach my $x (@{$config->{indexer}->{$field}->{'config'}}) { |
foreach my $x (@{$config->{indexer}->{$field}->{'config'}}) { |
465 |
|
|
466 |
|
$x = unroll_x($x); |
467 |
|
|
468 |
my $delimiter = x($x->{delimiter}) || ' '; |
my $delimiter = x($x->{delimiter}) || ' '; |
469 |
my $val = $cfg->val($database, x($x->{content})); |
my $val = $cfg->val($database, x($x->{content})); |
470 |
|
|
649 |
my $type_base = $type; |
my $type_base = $type; |
650 |
$type_base =~ s/_.+$//g; |
$type_base =~ s/_.+$//g; |
651 |
|
|
652 |
$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 ); |
653 |
|
|
654 |
# output current progress indicator |
# output current progress indicator |
655 |
my $last_p = 0; |
my $last_p = 0; |
919 |
|
|
920 |
all2xml.pl - read various file formats and dump XML for SWISH-E |
all2xml.pl - read various file formats and dump XML for SWISH-E |
921 |
|
|
922 |
|
=head1 SYNOPSYS |
923 |
|
|
924 |
|
$ all2xml.pl [test.conf] |
925 |
|
|
926 |
=head1 DESCRIPTION |
=head1 DESCRIPTION |
927 |
|
|
928 |
This command will read ISIS data file using OpenIsis perl module, MARC |
This command will read ISIS data file using OpenIsis perl module, MARC |
931 |
this script B<isn't general xml generator> from isis files (isis allready |
this script B<isn't general xml generator> from isis files (isis allready |
932 |
has something like that). Output of this script is tailor-made for SWISH-E. |
has something like that). Output of this script is tailor-made for SWISH-E. |
933 |
|
|
934 |
|
If no configuration file is specified, it will use default one called |
935 |
|
C<all2xml.conf>. |
936 |
|
|
937 |
=head1 BUGS |
=head1 BUGS |
938 |
|
|
939 |
Documentation is really lacking. However, in true Open Source spirit, source |
Documentation is really lacking. However, in true Open Source spirit, source |