1 |
#!/usr/bin/perl -w |
#!/usr/bin/perl -w |
2 |
|
|
3 |
use strict; |
use strict; |
4 |
use Biblio::Isis; |
use Biblio::Isis 0.23; |
5 |
use Getopt::Std; |
use Getopt::Std; |
6 |
use Data::Dumper; |
use Data::Dumper; |
7 |
use XML::Simple; |
use XML::Simple; |
76 |
|
|
77 |
my $last_field_name; # cache to prevent repeated fields |
my $last_field_name; # cache to prevent repeated fields |
78 |
|
|
79 |
|
my $broken_cdata = XMLin('<foo><![CDATA[<bar>]]></foo>') eq '<bar>>'; |
80 |
|
warn "XML::Simple on this system seems broken with <![CDATA[..]]>.\n" if ($broken_cdata); |
81 |
|
|
82 |
sub data2xml { |
sub data2xml { |
83 |
|
|
84 |
use xmlify; |
use xmlify; |
210 |
delete $x->{value}; |
delete $x->{value}; |
211 |
delete $x->{delimiter}; |
delete $x->{delimiter}; |
212 |
$x->{content} = $v; |
$x->{content} = $v; |
213 |
|
$d =~ s#>$## if ($d && $broken_cdata); |
214 |
$x->{delimiter} = $d; |
$x->{delimiter} = $d; |
215 |
} |
} |
216 |
return $x; |
return $x; |
710 |
$config=XMLin($import_xml_file, ForceArray => [ $tag, 'config', 'format' ], ForceContent => 1 ); |
$config=XMLin($import_xml_file, ForceArray => [ $tag, 'config', 'format' ], ForceContent => 1 ); |
711 |
|
|
712 |
# check for broken XML::Simple |
# check for broken XML::Simple |
713 |
if ( XMLin('<foo><![CDATA[<bar>]]></foo>') eq '<bar>>' ) { |
if ( $broken_cdata ) { |
|
warn "XML::Simple on this system seems broken with <![CDATA[..]]>.\n"; |
|
714 |
map { |
map { |
715 |
$config->{format}->{$_}->{content} =~ s#>$##; |
$config->{format}->{$_}->{content} =~ s#>$##; |
716 |
} keys %{ $config->{format} }; |
} keys %{ $config->{format} }; |
785 |
my $isis_db = $cfg -> val($database, 'isis_db') || die "$database doesn't have 'isis_db' defined!"; |
my $isis_db = $cfg -> val($database, 'isis_db') || die "$database doesn't have 'isis_db' defined!"; |
786 |
|
|
787 |
$import2cp = Text::Iconv->new($config->{isis_codepage},$codepage); |
$import2cp = Text::Iconv->new($config->{isis_codepage},$codepage); |
788 |
my $db = new Biblio::Isis( isisdb => $isis_db ); |
my $db = new Biblio::Isis( |
789 |
|
isisdb => $isis_db, |
790 |
|
join_subfields_with => ' ; ', |
791 |
|
); |
792 |
|
|
793 |
if (! $db) { |
if (! $db) { |
794 |
print STDERR "FATAL: can't read ISIS database: $isis_db, skipping...\n"; |
print STDERR "FATAL: can't read ISIS database: $isis_db, skipping...\n"; |