|
Lines 25-30
use strict;
Link Here
|
| 25 |
|
25 |
|
| 26 |
# please specify in which methods a given module is used |
26 |
# please specify in which methods a given module is used |
| 27 |
use MARC::Record; # marc2marcxml, marcxml2marc, changeEncoding |
27 |
use MARC::Record; # marc2marcxml, marcxml2marc, changeEncoding |
|
|
28 |
use MARC::File::MARCMaker; #marc2marcmaker |
| 28 |
use MARC::File::XML; # marc2marcxml, marcxml2marc, changeEncoding |
29 |
use MARC::File::XML; # marc2marcxml, marcxml2marc, changeEncoding |
| 29 |
use Biblio::EndnoteStyle; |
30 |
use Biblio::EndnoteStyle; |
| 30 |
use Unicode::Normalize; # _entity_encode |
31 |
use Unicode::Normalize; # _entity_encode |
|
Lines 58-63
$VERSION = 3.07.00.049;
Link Here
|
| 58 |
&marc2madsxml |
59 |
&marc2madsxml |
| 59 |
&marc2bibtex |
60 |
&marc2bibtex |
| 60 |
&marc2csv |
61 |
&marc2csv |
|
|
62 |
&marc2marcmaker |
| 61 |
&changeEncoding |
63 |
&changeEncoding |
| 62 |
); |
64 |
); |
| 63 |
|
65 |
|
|
Lines 854-859
sub marc2bibtex {
Link Here
|
| 854 |
return $tex; |
856 |
return $tex; |
| 855 |
} |
857 |
} |
| 856 |
|
858 |
|
|
|
859 |
=head2 marc2marcmaker - Convert from ISO-2709 to MARCMaker format |
| 860 |
|
| 861 |
my ( $error, $marcmaker) = marc2marcmaker( $marc, $biblionumber, $unimarc2marc21 ); |
| 862 |
|
| 863 |
Returns a MARCMaker format |
| 864 |
|
| 865 |
C<$marc> - an ISO-2709 or MARC::Record object |
| 866 |
|
| 867 |
C<$biblionumber> - The biblionumber of the record |
| 868 |
|
| 869 |
C<$unimarc2marc21> - Set to 1 to convert UNIMARC to MARC21 on the fly or 0 if don't (Only for UNIMARC environment) |
| 870 |
|
| 871 |
=cut |
| 872 |
|
| 873 |
sub marc2marcmaker { |
| 874 |
|
| 875 |
my ( $marc, $biblionumber, $unimarc2marc21 ) = @_; |
| 876 |
|
| 877 |
# global variables |
| 878 |
my ( $marc_mrk_output, $marcxml, $output_xsl, $marc_record_obj, $xsl, $error ); |
| 879 |
|
| 880 |
if ($marc =~ /^MARC::Record/) { # it's already a MARC::Record object |
| 881 |
($unimarc2marc21) ? |
| 882 |
$marcxml = C4::Record::marc2marcxml( $marc ) : |
| 883 |
$marc_record_obj = $marc; |
| 884 |
} elsif ( defined $biblionumber ) { |
| 885 |
($unimarc2marc21) ? |
| 886 |
$marcxml = C4::Biblio::GetXmlBiblio( $biblionumber ) : |
| 887 |
$marc_record_obj = GetMarcBiblio($biblionumber, 1); |
| 888 |
} else { # it's not a MARC::Record object, make it one |
| 889 |
eval { $marc_record_obj = MARC::Record->new_from_usmarc( $marc ) }; # handle exceptions |
| 890 |
} |
| 891 |
|
| 892 |
# conversion to MARC::Record object failed |
| 893 |
if ( $@ ) { |
| 894 |
$error .= "\nCreation of MARC::Record object failed: " . $MARC::Record::ERROR; |
| 895 |
carp "Creation of MARC::Record object failed."; |
| 896 |
} elsif ( $marc_record_obj->warnings() ) { |
| 897 |
carp "Warnings encountered while processing ISO-2709 record.\n"; |
| 898 |
my @warnings = $marc_record_obj->warnings(); |
| 899 |
foreach my $warn (@warnings) { |
| 900 |
carp "\t". $warn; |
| 901 |
}; |
| 902 |
} |
| 903 |
|
| 904 |
#Convert UNIMARC to MARC21 |
| 905 |
if ( C4::Context->preference('marcflavour') eq 'UNIMARC' and $unimarc2marc21 ) { |
| 906 |
$xsl = C4::Context->config('intrahtdocs') . '/prog/en/xslt/UNIMARC2MARC21.xsl'; |
| 907 |
my $xslt_engine = Koha::XSLT_Handler->new; |
| 908 |
$output_xsl = $xslt_engine->transform( $marcxml, $xsl ); |
| 909 |
my $err = $xslt_engine->err; # error number |
| 910 |
my $errstr = $xslt_engine->errstr; # error message |
| 911 |
if ( $err ) { |
| 912 |
$error .= "Error when processing $errstr Error number: $err\n"; |
| 913 |
carp "Error when processing $errstr Error number: $err\n"; |
| 914 |
} else { |
| 915 |
$marc_record_obj = C4::Record::marcxml2marc( $output_xsl, 'UTF-8', 'MARC21' ); |
| 916 |
} |
| 917 |
} |
| 918 |
|
| 919 |
unless ($error) { # if no errors makes MARCMaker convertion |
| 920 |
$marc_mrk_output = MARC::File::MARCMaker->encode($marc_record_obj); |
| 921 |
} |
| 922 |
|
| 923 |
return ( $error, $marc_mrk_output ); |
| 924 |
|
| 925 |
} |
| 857 |
|
926 |
|
| 858 |
=head1 INTERNAL FUNCTIONS |
927 |
=head1 INTERNAL FUNCTIONS |
| 859 |
|
928 |
|