/[webpac2]/trunk/lib/WebPAC/Normalize/MARC.pm
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/lib/WebPAC/Normalize/MARC.pm

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

revision 1023 by dpavlin, Sat Nov 10 11:13:58 2007 UTC revision 1024 by dpavlin, Sat Nov 10 11:37:47 2007 UTC
# Line 80  sub marc_template { Line 80  sub marc_template {
80    
81          my $fields_re = join('|', keys %$to_subfields );          my $fields_re = join('|', keys %$to_subfields );
82    
         my $fill_in;  
83          my @marc_out;          my @marc_out;
84            
85          my $marc_template;          our $_template;
         _parse_template( $args->{marc_template}, $marc_template );  
86    
87          sub _parse_template {          sub _parse_template {
88                  my ( $templates, $marc_template_order ) = @_;                  my ( $name, $templates ) = @_;
89    
90                  foreach my $template ( @{ $templates } ) {                  foreach my $template ( @{ $templates } ) {
91                          our $count = {};                          our $count = {};
# Line 102  sub marc_template { Line 100  sub marc_template {
100                          $pos_template =~ s/($fields_re)/my_count($1)/ge;                          $pos_template =~ s/($fields_re)/my_count($1)/ge;
101                          my $count_key = dump( $count );                          my $count_key = dump( $count );
102                          warn "### template: |$template| -> |$pos_template| count = $count_key marc_order = ",dump( @marc_order ),$/;                          warn "### template: |$template| -> |$pos_template| count = $count_key marc_order = ",dump( @marc_order ),$/;
103                          $marc_template->{pos}->{ $count_key } = $pos_template;                          $_template->{$name}->{pos}->{ $count_key } = $pos_template;
104                          $marc_template->{order}->{ $pos_template } = [ @marc_order ];                          $_template->{$name}->{order}->{ $pos_template } = [ @marc_order ];
105                  }                  }
106                  warn "### from ",dump( $templates ), " created ", dump( $marc_template );                  warn "### from ",dump( $templates ), " created ", dump( $_template );
107          }          }
108    
109          warn "### marc_template = ",dump( $marc_template );          _parse_template( 'marc', $args->{marc_template} );
110            _parse_template( 'isis', $args->{isis_template} );
111            warn "### _template = ",dump( $_template );
112    
113          my $m;          my $m;
114    
# Line 141  sub marc_template { Line 141  sub marc_template {
141                  warn "### from_count = ",dump( $from_count ), $/;                  warn "### from_count = ",dump( $from_count ), $/;
142                  warn "### to_count   = ",dump( $to_count ), $/;                  warn "### to_count   = ",dump( $to_count ), $/;
143    
144                  my $template = $marc_template->{pos}->{ $from_count_key } ||                  my $template = $_template->{marc}->{pos}->{ $from_count_key } ||
145                          die "I don't have template for:\n$from_count_key\n## available templates\n", dump( $marc_template->{pos} );                          die "I don't have template for:\n$from_count_key\n## available templates\n", dump( $_template );
146    
147                  warn "### selected template: |$template|\n";                  warn "### selected template: |$template|\n";
148    
149                  $fill_in = {};                  our $fill_in = {};
150    
151                  my @templates = split(/\|/, $template );                  my @templates = split(/\|/, $template );
152                  @templates = ( $template );                  @templates = ( $template );
# Line 172  sub marc_template { Line 172  sub marc_template {
172                          warn "#### >>>> $sf with fill_in = ",dump( $fill_in ),$/;                          warn "#### >>>> $sf with fill_in = ",dump( $fill_in ),$/;
173                  }                  }
174    
175                  warn "## template: |$template|\n## marc_template = ",dump( $marc_template );                  warn "## template: |$template|\n## _template->marc = ",dump( $_template->{marc} );
176    
177                  foreach my $sf ( @{ $marc_template->{order}->{$template} } ) {                  foreach my $sf ( @{ $_template->{marc}->{order}->{$template} } ) {
178                          my ( $sf, $nr ) = @$sf;                          my ( $sf, $nr ) = @$sf;
179                          my $v = $fill_in->{$sf}->[$nr] || die "can't find fill_in $sf/$nr";                          my $v = $fill_in->{$sf}->[$nr] || die "can't find fill_in $sf/$nr";
180                          warn "++ $sf/$nr |$v|\n";                          warn "++ $sf/$nr |$v|\n";

Legend:
Removed from v.1023  
changed lines
  Added in v.1024

  ViewVC Help
Powered by ViewVC 1.1.26