+ print STDERR "Reading database: $isis_db [$max_rowid rows]\n";
+
+ my $path = $database;
+
+ for (my $row_id = 1; $row_id <= $max_rowid; $row_id++ ) {
+ my $row = OpenIsis::read( $db, $row_id );
+ if ($row && $row->{mfn}) {
+
+ progress($row->{mfn}, $max_rowid);
+
+ my $swishpath = $path."#".int($row->{mfn});
+
+ if (my $xml = data2xml($type_base,$row,$add_xml,$cfg,$database)) {
+ $xml = $cp2utf->convert($xml);
+ use bytes; # as opposed to chars
+ print "Path-Name: $swishpath\n";
+ print "Content-Length: ".(length($xml)+1)."\n";
+ print "Document-Type: XML\n\n$xml\n";
+ }
+ }
+ }
+ # for this to work with current version of OpenIsis (0.9.0)
+ # you might need my patch from
+ # http://www.rot13.org/~dpavlin/projects/openisis-0.9.0-perl_close.diff
+ OpenIsis::close($db);
+ print STDERR "\n";
+
+ } elsif ($type_base eq "excel") {
+ require Spreadsheet::ParseExcel;
+ require Spreadsheet::ParseExcel::Utility;
+ import Spreadsheet::ParseExcel::Utility qw(int2col);
+
+ $import2cp = Text::Iconv->new($config->{excel_codepage},$codepage);
+ my $excel_file = $cfg -> val($database, 'excel_file') || die "$database doesn't have 'excel_file' defined!";
+
+ my $sheet = x($config->{sheet}) || die "no sheet in $type.xml";
+ my $start_row = x($config->{start_row}) - 1 || die "no start_row in $type.xml";
+
+ my $oBook = Spreadsheet::ParseExcel::Workbook->Parse($excel_file) || die "can't open Excel file '$excel_file'";
+
+ my $sheet_nr = 0;
+ foreach my $oWks (@{$oBook->{Worksheet}}) {
+ #print STDERR "-- SHEET $sheet_nr:", $oWks->{Name}, "\n";
+ last if ($oWks->{Name} eq $sheet);
+ $sheet_nr++;
+ }
+
+ my $oWorksheet = $oBook->{Worksheet}[$sheet_nr];
+
+ print STDERR "using sheet: ",$oWorksheet->{Name},"\n";
+ defined ($oWorksheet) || die "can't find sheet '$sheet' in $excel_file";
+ my $end_row = x($config->{end_row}) || $oWorksheet->{MaxRow};
+
+ for(my $iR = $start_row ; defined $end_row && $iR <= $end_row ; $iR++) {
+ my $row;
+ for(my $iC = $oWorksheet->{MinCol} ; defined $oWorksheet->{MaxCol} && $iC <= $oWorksheet->{MaxCol} ; $iC++) {
+ my $cell = $oWorksheet->{Cells}[$iR][$iC];
+ if ($cell) {
+ $row->{int2col($iC)} = $cell->Value;
+ }
+ }
+
+ progress($iR, $end_row);
+
+# print "row[$iR/$end_row] ";
+# foreach (keys %{$row}) {
+# print "$_: ",$row->{$_},"\t";
+# }
+# print "\n";
+
+ my $swishpath = $database."#".$iR;
+
+ next if (! $row);
+
+ if (my $xml = data2xml($type_base,$row,$add_xml,$cfg,$database)) {
+ $xml = $cp2utf->convert($xml);
+ use bytes; # as opposed to chars
+ print "Path-Name: $swishpath\n";
+ print "Content-Length: ".(length($xml)+1)."\n";
+ print "Document-Type: XML\n\n$xml\n";
+ }
+ }
+ } elsif ($type_base eq "marc") {
+
+ require MARC;
+
+ $import2cp = Text::Iconv->new($config->{marc_codepage},$codepage);
+ my $marc_file = $cfg -> val($database, 'marc_file') || die "$database doesn't have 'marc_file' defined!";
+
+ # optional argument is format
+ my $format = x($config->{marc_format}) || 'usmarc';
+
+ print STDERR "Reading MARC file '$marc_file'\n";
+
+ my $marc = new MARC;
+ my $nr = $marc->openmarc({
+ file=>$marc_file, format=>$format
+ }) || die "Can't open MARC file '$marc_file' with format '$format'";
+
+ # read MARC file in memory
+ $marc->nextmarc(-1);
+
+ my $max_rec = $marc->marc_count();
+
+ for(my $i=1; $i<=$max_rec; $i++) {
+
+ progress($i,$max_rec);
+
+ # store value for marc_sf.pm
+ $main::cache->{marc_record} = $i;
+
+ my $swishpath = $database."#".$i;
+
+ if (my $xml = data2xml($type_base,$marc,$add_xml,$cfg,$database)) {