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

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

revision 730 by dpavlin, Thu Apr 13 19:44:51 2006 UTC revision 750 by dpavlin, Sun Oct 29 16:34:25 2006 UTC
# Line 1  Line 1 
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;
# Line 76  my $use_lhash_cache = 1; Line 76  my $use_lhash_cache = 1;
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;
# Line 207  sub data2xml { Line 210  sub data2xml {
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;
# Line 488  sub data2xml { Line 492  sub data2xml {
492                          if ($val) {                          if ($val) {
493                                  $display_data .= $delimiter.$val if ($d);                                  $display_data .= $delimiter.$val if ($d);
494                                  $swish_data .= " ".$val if ($s);                                  $swish_data .= " ".$val if ($s);
495                                  $index->insert($field, $val, $path) if ($i);                                  $index->insert($field, $val, $val, $path) if ($i);
496                          }                          }
497    
498                          if ($iterate_by_page) {                          if ($iterate_by_page) {
# Line 705  foreach my $database ($cfg->Sections) { Line 709  foreach my $database ($cfg->Sections) {
709          my $tag = $cfg->val($database, 'import_xml_tag') || $type2tag{$type_base} || die "can't find which tag to use for type $type";          my $tag = $cfg->val($database, 'import_xml_tag') || $type2tag{$type_base} || die "can't find which tag to use for type $type";
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
713            if ( $broken_cdata ) {
714                    map {
715                            $config->{format}->{$_}->{content} =~ s#>$##;
716                    } keys %{ $config->{format} };
717            }
718    
719          # helper for progress bar          # helper for progress bar
720          sub fmt_time {          sub fmt_time {
721                  my $t = shift || 0;                  my $t = shift || 0;
# Line 774  foreach my $database ($cfg->Sections) { Line 785  foreach my $database ($cfg->Sections) {
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";

Legend:
Removed from v.730  
changed lines
  Added in v.750

  ViewVC Help
Powered by ViewVC 1.1.26