2 ## This script allows you to export a rel_2_2 bibliographic db in
3 #MARC21 format from the command line.
12 my ( $out_marc_file, $check) ;
14 'file:s' => \$out_marc_file,
19 ## export_xml_koharecords -file somefilename -c 1
20 ## use the -c flag if you want to check whether you xml is proper or not. Advisable but very slow
21 open(OUT,">" ,$out_marc_file) or die $!;
23 my $dbh= C4::Context->dbh;
27 $sth=$dbh->prepare("select biblionumber,marcxml from biblio order by biblionumber ");
28 my $sth2=$dbh->prepare("select marcxml from items where biblionumber =?");
31 my $header=&collection_header;
32 print OUT '<?xml version="1.0" encoding="UTF-8"?>'."\n";
34 while (my ($biblionumber,$marcxml) = $sth->fetchrow) {
38 $hash=XMLin($marcxml);
39 }; ### is it a proper xml? broken xml may crash ZEBRA- slow but safe
47 print OUT "<koharecord>\n";
49 print OUT "<holdings>";
50 $sth2->execute($biblionumber);
51 while (my ($itemxml)=$sth2->fetchrow){
54 $hash=XMLin($itemxml);
55 }; ### is it a proper xml? broken xml may crash ZEBRA- slow but safe
65 print OUT "</holdings></koharecord>\n";
67 print OUT "</kohacollection>\n";
70 sub collection_header {
71 #### this one is for koha collection
73 my $enc = shift || 'UTF-8';
74 return( <<KOHA_XML_HEADER );
76 <kohacollection xmlns:marc="http://loc.gov/MARC21/slim" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://library.neu.edu.tr/kohanamespace/koharecord.xsd">