Bugzilla – Attachment 66695 Details for
Bug 17797
Add XSLT_Handler in opac/unapi
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 17797: Add XSLT_Handler in opac/unapi
Bug-17797-Add-XSLTHandler-in-opacunapi.patch (text/plain), 2.74 KB, created by
Nick Clemens (kidclamp)
on 2017-09-01 09:51:15 UTC
(
hide
)
Description:
Bug 17797: Add XSLT_Handler in opac/unapi
Filename:
MIME Type:
Creator:
Nick Clemens (kidclamp)
Created:
2017-09-01 09:51:15 UTC
Size:
2.74 KB
patch
obsolete
>From d99da18bcc41d8349a13930ea43a654ecbbc30fc Mon Sep 17 00:00:00 2001 >From: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> >Date: Tue, 20 Dec 2016 16:58:05 +0100 >Subject: [PATCH] Bug 17797: Add XSLT_Handler in opac/unapi > >Replaces some code by a call to existing module. >Removes the $@->code and $@->message calls. > >Test plan >[1] Run /cgi-bin/koha/unapi?id=koha:biblionumber:[number]&format=marcxml >[2] Try some variations. > >Signed-off-by: Josef Moravec <josef.moravec@gmail.com> > >Signed-off-by: Nick Clemens <nick@bywatersolutions.com> >--- > opac/unapi | 27 +++++++++++---------------- > 1 file changed, 11 insertions(+), 16 deletions(-) > >diff --git a/opac/unapi b/opac/unapi >index 912e5bd..d06fa44 100755 >--- a/opac/unapi >+++ b/opac/unapi >@@ -40,8 +40,7 @@ an XML format such as OAI DC, RSS2, MARCXML, or MODS. > use CGI qw ( -utf8 ); > use C4::Context; > use C4::Biblio; >-use XML::LibXML; >-use XML::LibXSLT; >+use Koha::XSLT_Handler; > > my $cgi = CGI->new(); > binmode(STDOUT, ":encoding(UTF-8)"); #output as utf8 >@@ -138,18 +137,19 @@ if (not defined $format) { > exit 0; > } > >- my $transformer = get_transformer($format, $format_to_stylesheet_map, $format_info); >- unless (defined $transformer) { >+ my $xslt_file = get_xslt_file( $format, $format_to_stylesheet_map, $format_info ); >+ unless( defined $xslt_file ) { > 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 = $transformer->output_as_chars( $record_dom ); >+ my $xslt_engine = Koha::XSLT_Handler->new; >+ $content = $xslt_engine->transform({ >+ xml => $marcxml, >+ file => $xslt_file, >+ }); > }; > if ($@) { >- print $cgi->header( -status => '500 internal error ' . $@->code() . ": " . $@->message() ); >+ print $cgi->header( -status => '500 internal error ' . $@ ); > exit 0; > } > >@@ -193,7 +193,7 @@ sub emit_formats { > } > > >-sub get_transformer { >+sub get_xslt_file { > my ($format, $format_to_stylesheet_map, $format_info) = @_; > $format = lc $format; > >@@ -204,12 +204,7 @@ sub get_transformer { > "/prog/en/xslt/" . > $format_to_stylesheet_map->{$marcflavour}->{$format}; > >- my $parser = XML::LibXML->new(); >- my $xslt = XML::LibXSLT->new(); >- my $style_doc = $parser->parse_file( $xslt_file ); >- my $stylesheet = $xslt->parse_stylesheet( $style_doc ); >- >- return $stylesheet; >+ return $xslt_file; > } > > =head1 AUTHOR >-- >2.1.4
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 17797
:
58305
|
63947
| 66695