#
# This file is part of Koha.
#
-# Koha is free software; you can redistribute it and/or modify it under the
-# terms of the GNU General Public License as published by the Free Software
-# Foundation; either version 2 of the License, or (at your option) any later
-# version.
+# Koha is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
#
-# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
-# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
-# A PARTICULAR PURPOSE. See the GNU General Public License for more details.
+# Koha is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
#
-# You should have received a copy of the GNU General Public License along with
-# Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
-# Suite 330, Boston, MA 02111-1307 USA
+# You should have received a copy of the GNU General Public License
+# along with Koha; if not, see <http://www.gnu.org/licenses>.
use strict;
use warnings;
=cut
-use CGI;
+use CGI qw ( -utf8 );
use C4::Context;
use C4::Biblio;
use XML::LibXML;
use XML::LibXSLT;
my $cgi = CGI->new();
-binmode(STDOUT, "utf8"); #output as utf8
+binmode(STDOUT, ":encoding(UTF-8)"); #output as utf8
=head1 VARIABLES
'rss2-full' => 'MARC21slim2RSS2.xsl',
'srw_dc' => 'MARC21slim2SRWDC.xsl',
},
+ 'NORMARC' => {
+ 'marcxml' => 'identity.xsl',
+ 'marcxml-full' => 'identity.xsl',
+ 'mods' => 'MARC21slim2MODS.xsl',
+ 'mods-full' => 'MARC21slim2MODS.xsl',
+ 'mods3' => 'MARC21slim2MODS3-1.xsl',
+ 'mods3-full' => 'MARC21slim2MODS3-1.xsl',
+ 'oai_dc' => 'MARC21slim2OAIDC.xsl',
+ 'rdfdc', => 'MARC21slim2RDFDC.xsl',
+ 'rss2' => 'MARC21slim2RSS2.xsl',
+ 'rss2-full' => 'MARC21slim2RSS2.xsl',
+ 'srw_dc' => 'MARC21slim2SRWDC.xsl',
+ },
'UNIMARC' => {
'marcxml' => 'identity.xsl',
'marcxml-full' => 'identity.xsl',
'oai_dc' => 'UNIMARCslim2OAIDC.xsl',
+ 'rdfdc', => 'UNIMARCslim2RDFDC.xsl',
+ 'srw_dc' => 'UNIMARCslim2SRWDC.xsl',
},
};
my $format = $cgi->param('format');
if (not defined $format) {
- emit_formats($id);
+ emit_formats($id, $format_to_stylesheet_map, $format_info, $cgi);
} elsif ($id) {
# koha:biblionumber:0152018484
exit 0;
}
- my $transformer = get_transformer($format);
+ my $transformer = get_transformer($format, $format_to_stylesheet_map, $format_info);
unless (defined $transformer) {
print $cgi->header( -status => '406 invalid format requested' );
exit 0;
my $parser = XML::LibXML->new();
my $record_dom = $parser->parse_string( $marcxml );
$record_dom = $transformer->transform( $record_dom );
- $content = $record_dom->toString();
+ $content = $transformer->output_as_chars( $record_dom );
};
if ($@) {
print $cgi->header( -status => '500 internal error ' . $@->code() . ": " . $@->message() );
exit 0;
}
- print $cgi->header( -type =>'application/xml' );
+ print $cgi->header( -type =>'application/xml', -charset => 'UTF-8' );
print $content;
} else {
# ID is obviously wrong, so 404
exit 0;
sub emit_formats {
- my $id = shift;
+ my ($id, $format_to_stylesheet_map, $format_info, $cgi) = @_;
if (defined $id) {
print $cgi->header( -type =>'application/xml', -status => '300 multiple choices' );
} else {
- print $cgi->header( -type =>'application/xml' );
+ print $cgi->header( -type =>'application/xml', -status => '200 Ok' );
}
print "<?xml version='1.0' encoding='utf-8' ?>\n";
sub get_transformer {
- my $format = lc shift;
+ my ($format, $format_to_stylesheet_map, $format_info) = @_;
+ $format = lc $format;
my $marcflavour = uc(C4::Context->preference('marcflavour'));
return unless $format_to_stylesheet_map->{$marcflavour}->{$format};
- my $xslt_file = C4::Context->config('intranetdir') .
- "/koha-tmpl/intranet-tmpl/prog/en/xslt/" .
+ my $xslt_file = C4::Context->config('intrahtdocs') .
+ "/prog/en/xslt/" .
$format_to_stylesheet_map->{$marcflavour}->{$format};
my $parser = XML::LibXML->new();
=head1 AUTHOR
-Koha Development team <info@koha.org>
+Koha Development Team <http://koha-community.org/>
Originally written by Joshua Ferraro <jmf@liblime.com>