11 |
my $i = shift || 0; # isis repeatable number |
my $i = shift || 0; # isis repeatable number |
12 |
my $codepage = shift || die "parse_format must be called with codepage!"; |
my $codepage = shift || die "parse_format must be called with codepage!"; |
13 |
if ($type eq "isis") { |
if ($type eq "isis") { |
14 |
return parse_isis_format($format,$row,$i,$codepage); |
return parse_iso_format($format,$row,$i,$codepage,'isis_sf'); |
15 |
} elsif ($type eq "excel") { |
} elsif ($type eq "excel") { |
16 |
return parse_excel_format($format,$row,$i,$codepage); |
return parse_excel_format($format,$row,$i,$codepage); |
17 |
|
} elsif ($type eq "marc") { |
18 |
|
return parse_iso_format($format,$row,$i,$codepage,'marc_sf'); |
19 |
} |
} |
20 |
} |
} |
21 |
|
|
22 |
#------------------------------------------------------------- |
#------------------------------------------------------------- |
23 |
|
|
24 |
sub parse_isis_format { |
sub parse_iso_format { |
|
use isis_sf; |
|
25 |
|
|
26 |
my $format = shift; |
my $format = shift; |
27 |
my $row = shift; |
my $row = shift; |
28 |
my $i = shift; |
my $i = shift; |
29 |
my $codepage = shift; |
my $codepage = shift; |
30 |
|
|
31 |
|
my $func = shift || die "need to know which sub-field function to use"; |
32 |
|
|
33 |
|
require $func.".pm"; |
34 |
|
|
35 |
my $out; |
my $out; |
36 |
my $out_swish; |
my $out_swish; |
37 |
|
|
43 |
my $display; |
my $display; |
44 |
my $swish; |
my $swish; |
45 |
|
|
46 |
|
sub cnv_cp { |
47 |
|
my $tmp = shift; |
48 |
|
if ($codepage) { |
49 |
|
$tmp = $codepage->convert($tmp) || print STDERR "$1$2 = '$tmp' can't convert"; |
50 |
|
} |
51 |
|
return $tmp; |
52 |
|
} |
53 |
|
|
54 |
while ($format) { |
while ($format) { |
55 |
#print STDERR "\n#### $format"; |
#print STDERR "\n#### $format"; |
56 |
if ($format =~ s/^(\d\d\d)(\w?)//) { |
# this is EBSCO special to support numeric subfield in |
57 |
my $tmp = isis_sf($row,$1,$2,$i); |
# form of 856#3 |
58 |
|
if ($format =~ s/^(\d\d\d)#*(\w?)//) { |
59 |
|
my $tmp = get_sf($row,$1,$2,$i); |
60 |
if ($tmp) { |
if ($tmp) { |
61 |
if ($codepage) { |
$display .= $prefix.cnv_cp($tmp); |
|
$tmp = $codepage->convert($tmp) || warn "row: ",$row->{mfn},", $1$2 '$tmp' can't convert"; |
|
|
} |
|
|
$display .= $prefix . $tmp; |
|
62 |
$swish .= $tmp." "; |
$swish .= $tmp." "; |
63 |
#print STDERR " == $tmp"; |
#print STDERR " == $tmp"; |
64 |
} |
} |
67 |
# (as opposed to 010 and 011) so they are strictly listed |
# (as opposed to 010 and 011) so they are strictly listed |
68 |
# here |
# here |
69 |
} elsif ($format =~ s/^(1[01])//) { |
} elsif ($format =~ s/^(1[01])//) { |
70 |
my $tmp = isis_sf($row,$1,undef,$i); |
my $tmp = get_sf($row,$1,undef,$i); |
71 |
if ($tmp) { |
if ($tmp) { |
72 |
if ($codepage) { |
$display .= $prefix.cnv_cp($tmp); |
|
$tmp = $codepage->convert($tmp) || warn "row: ",$row->{mfn},", $1$2 '$tmp' can't convert"; |
|
|
} |
|
|
$display .= $prefix . $tmp; |
|
73 |
$swish .= $tmp." "; |
$swish .= $tmp." "; |
74 |
} |
} |
75 |
$prefix = ""; |
$prefix = ""; |