16 |
return parse_excel_format($format,$row,$i,$codepage); |
return parse_excel_format($format,$row,$i,$codepage); |
17 |
} elsif ($type eq "marc") { |
} elsif ($type eq "marc") { |
18 |
return parse_iso_format($format,$row,$i,$codepage,'marc_sf'); |
return parse_iso_format($format,$row,$i,$codepage,'marc_sf'); |
19 |
|
} elsif ($type eq "feed") { |
20 |
|
return parse_feed_format($format,$row,$i,$codepage); |
21 |
} |
} |
22 |
} |
} |
23 |
|
|
46 |
my $swish; |
my $swish; |
47 |
|
|
48 |
sub cnv_cp { |
sub cnv_cp { |
49 |
my $tmp = shift; |
my $codepage = shift; |
50 |
|
my $tmp = shift || return; |
51 |
if ($codepage) { |
if ($codepage) { |
52 |
$tmp = $codepage->convert($tmp) || print STDERR "$1$2 = '$tmp' can't convert"; |
$tmp = $codepage->convert($tmp) || print STDERR "iso: '$tmp' can't convert\n"; |
53 |
} |
} |
54 |
return $tmp; |
return $tmp; |
55 |
} |
} |
59 |
# this is EBSCO special to support numeric subfield in |
# this is EBSCO special to support numeric subfield in |
60 |
# form of 856#3 |
# form of 856#3 |
61 |
if ($format =~ s/^(\d\d\d)#*(\w?)//) { |
if ($format =~ s/^(\d\d\d)#*(\w?)//) { |
62 |
my $tmp = get_sf($row,$1,$2,$i); |
my $tmp = cnv_cp($codepage,get_sf($row,$1,$2,$i)); |
63 |
if ($tmp) { |
if ($tmp) { |
64 |
$display .= $prefix.cnv_cp($tmp); |
$display .= $prefix.$tmp; |
65 |
$swish .= $tmp." "; |
$swish .= $tmp." "; |
66 |
#print STDERR " == $tmp"; |
#print STDERR " == $tmp"; |
67 |
} |
} |
70 |
# (as opposed to 010 and 011) so they are strictly listed |
# (as opposed to 010 and 011) so they are strictly listed |
71 |
# here |
# here |
72 |
} elsif ($format =~ s/^(1[01])//) { |
} elsif ($format =~ s/^(1[01])//) { |
73 |
my $tmp = get_sf($row,$1,undef,$i); |
my $tmp = cnv_cp($codepage,get_sf($row,$1,undef,$i)); |
74 |
if ($tmp) { |
if ($tmp) { |
75 |
$display .= $prefix.cnv_cp($tmp); |
$display .= $prefix.$tmp; |
76 |
$swish .= $tmp." "; |
$swish .= $tmp." "; |
77 |
} |
} |
78 |
$prefix = ""; |
$prefix = ""; |
105 |
my $i = shift; |
my $i = shift; |
106 |
my $codepage = shift; |
my $codepage = shift; |
107 |
|
|
108 |
|
return if ($i > 0); # Excel doesn't support repeatable fields |
109 |
|
|
110 |
my $out; |
my $out; |
111 |
my $out_swish; |
my $out_swish; |
112 |
|
|
147 |
return ($swish,$display); |
return ($swish,$display); |
148 |
} |
} |
149 |
|
|
150 |
|
#------------------------------------------------------------- |
151 |
|
|
152 |
|
sub parse_feed_format { |
153 |
|
my $format = shift; |
154 |
|
my $data = shift; |
155 |
|
my $i = shift; |
156 |
|
my $codepage = shift; |
157 |
|
|
158 |
|
my $out; |
159 |
|
my $out_swish; |
160 |
|
|
161 |
|
my $prefix = ""; |
162 |
|
if ($format =~ s/^([^\d\|]{1,3})//) { |
163 |
|
$prefix = $1; |
164 |
|
} |
165 |
|
|
166 |
|
my $display; |
167 |
|
my $swish; |
168 |
|
|
169 |
|
while ($format && length($format) > 0) { |
170 |
|
#print STDERR "\n#### $format #"; |
171 |
|
if ($format =~ s/^\|(\d+)\|//) { |
172 |
|
#print STDERR "--$1-> $format -[",length($format),"] "; |
173 |
|
if ($data->{$1}) { |
174 |
|
my $tmp = $data->{$1}; |
175 |
|
if ($codepage) { |
176 |
|
$tmp = $codepage->convert($tmp) || warn "feed: $1 '$tmp' can't convert\n"; |
177 |
|
} |
178 |
|
$display .= $prefix . $tmp; |
179 |
|
$swish .= $tmp." "; |
180 |
|
#print STDERR " == $tmp"; |
181 |
|
} |
182 |
|
$prefix = ""; |
183 |
|
} elsif ($format =~ s/^([^\d\|]+)(\|\d+\|)/$2/) { |
184 |
|
$prefix .= $1 if ($display); |
185 |
|
} else { |
186 |
|
print STDERR "unparsed format: $format\n"; |
187 |
|
$prefix .= $format; |
188 |
|
$format = ""; |
189 |
|
} |
190 |
|
#print STDERR " display: $display swish: $swish [format: $format]"; |
191 |
|
} |
192 |
|
# add suffix |
193 |
|
$display .= $prefix if ($display); |
194 |
|
|
195 |
|
return ($swish,$display); |
196 |
|
} |
197 |
|
|
198 |
|
#------------------------------------------------------------- |
199 |
|
|
200 |
1; |
1; |