1 #-------------------------------------------------------------
8 my $type = shift || die "parset_format must be called with type!";
9 my $format = shift || die "parse_format must be called with format!";
10 my $row = shift || die "parse_format must be called with row!";
11 my $i = shift || 0; # isis repeatable number
12 my $codepage = shift || die "parse_format must be called with codepage!";
13 if ($type eq "isis") {
14 return parse_iso_format($format,$row,$i,$codepage,'isis_sf');
15 } elsif ($type eq "excel") {
16 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 } elsif ($type eq "feed") {
20 return parse_feed_format($format,$row,$i,$codepage);
24 #-------------------------------------------------------------
26 sub parse_iso_format {
33 my $func = shift || die "need to know which sub-field function to use";
41 if ($format =~ s/^([^\d]+)//) {
51 $tmp = $codepage->convert($tmp) || print STDERR "$1$2 = '$tmp' can't convert";
57 #print STDERR "\n#### $format";
58 # this is EBSCO special to support numeric subfield in
60 if ($format =~ s/^(\d\d\d)#*(\w?)//) {
61 my $tmp = get_sf($row,$1,$2,$i);
63 $display .= $prefix.cnv_cp($tmp);
65 #print STDERR " == $tmp";
68 # this might be our local scpeciality -- fields 10 and 11
69 # (as opposed to 010 and 011) so they are strictly listed
71 } elsif ($format =~ s/^(1[01])//) {
72 my $tmp = get_sf($row,$1,undef,$i);
74 $display .= $prefix.cnv_cp($tmp);
78 } elsif ($format =~ s/^mfn//i) {
79 $display .= $prefix . $row->{mfn};
81 } elsif ($format =~ s/^([^\d]+)(\d{0,3})/$2/) {
82 $prefix .= $1 if ($display);
83 } elsif ($format =~ s/^([^\d]+\d{0,2})//) {
84 $prefix .= $1 if ($display);
85 } elsif ($format =~ s/^(\d{1,2})//) {
86 $prefix .= $1 if ($display);
88 print STDERR "unparsed format: $format\n";
94 $display .= $prefix if ($display);
96 return ($swish,$display);
99 #-------------------------------------------------------------
101 sub parse_excel_format {
105 my $codepage = shift;
111 if ($format =~ s/^([^A-Z\|]{1,3})//) {
118 while ($format && length($format) > 0) {
119 #print STDERR "\n#### $format #";
120 if ($format =~ s/^\|([A-Z]{1,2})\|//) {
121 #print STDERR "--$1-> $format -[",length($format),"] ";
123 my $tmp = $row->{$1};
125 $tmp = $codepage->convert($tmp) || warn "excel: $1 '$tmp' can't convert";
127 $display .= $prefix . $tmp;
129 #print STDERR " == $tmp";
132 } elsif ($format =~ s/^([^A-Z\|]+)(\|[A-Z]{1,2}\|)/$2/) {
133 $prefix .= $1 if ($display);
135 print STDERR "unparsed format: $format\n";
139 #print STDERR " display: $display swish: $swish [format: $format]";
142 $display .= $prefix if ($display);
144 return ($swish,$display);
147 #-------------------------------------------------------------
149 sub parse_feed_format {
153 my $codepage = shift;
159 if ($format =~ s/^([^\d\|]{1,3})//) {
166 while ($format && length($format) > 0) {
167 #print STDERR "\n#### $format #";
168 if ($format =~ s/^\|(\d+)\|//) {
169 #print STDERR "--$1-> $format -[",length($format),"] ";
171 my $tmp = $data->{$1};
173 $tmp = $codepage->convert($tmp) || warn "feed: $1 '$tmp' can't convert\n";
175 $display .= $prefix . $tmp;
177 #print STDERR " == $tmp";
180 } elsif ($format =~ s/^([^\d\|]+)(\|\d+\|)/$2/) {
181 $prefix .= $1 if ($display);
183 print STDERR "unparsed format: $format\n";
187 #print STDERR " display: $display swish: $swish [format: $format]";
190 $display .= $prefix if ($display);
192 return ($swish,$display);
195 #-------------------------------------------------------------