4 # find Koha's Perl modules
5 # test carefully before changing this
7 eval { require "$FindBin::Bin/../../kohalib.pl" };
10 use MARC
::File
::XML
(BinaryEncoding
=>"utf8");
12 use C4
::AuthoritiesMarc
;
14 MARC
::File
::XML
::default_record_format
("UNIMARCAUTH");
15 my $dbh = C4
::Context
->dbh;
16 my $rq= $dbh->prepare(qq|
20 my $filename= shift @ARGV;
22 #ATTENTION : Mettre la base en utf8 auparavant.
23 #BEWARE : Set database into utf8 before.
24 while (my ($authid)=$rq->fetchrow){
25 open my $fileoutput, '>:encoding(UTF-8)', "./$filename/$authid.xml" or die "unable to open $filename";
26 my $record=AUTHgetauthority
($dbh,$authid);
27 if (! utf8
::is_utf8
($record)) {
28 utf8
::decode
($record);
31 # if (C4::Context->preference('marcflavour') eq "UNIMARC"){
32 $record->leader(' nac 22 1u 4500');
33 my $string = ($time=~m/([0-9\-]+)/) ?
$1 : undef
35 $string = sprintf("%-*s",26, $string);
36 substr($string,9,6,"frey50");
37 unless ($record->subfield(100,"a")){
38 $record->insert_fields_ordered(MARC
::Field
->new(100,"","","a"=>$string));
40 unless ($record->subfield('001')){
41 $record->insert_fields_ordered(MARC
::Field
->new('001',$authid));
44 # $record->encoding( 'UTF-8' );
46 print {$fileoutput} $record->as_xml();