From: Frederic Demians Date: Thu, 5 Feb 2009 07:26:13 +0000 (+0100) Subject: Avoid XSLT stylesheet building for each biblio record to transform X-Git-Tag: new_acq_a_porter~563 X-Git-Url: http://koha-dev.rot13.org:8081/gitweb/?a=commitdiff_plain;ds=sidebyside;h=eaa3ee40a7bf9c531954593877816f7d707efa9a;p=koha-ffzg.git Avoid XSLT stylesheet building for each biblio record to transform In XSLT.pm, put XSLT stylesheet object in a session variable in order to avoid to build it for each biblio to parse: useful on search result page. Signed-off-by: Galen Charlton --- diff --git a/C4/XSLT.pm b/C4/XSLT.pm index eeb2ec73a2..1bea9f1aaf 100644 --- a/C4/XSLT.pm +++ b/C4/XSLT.pm @@ -106,6 +106,8 @@ sub getAuthorisedValues4MARCSubfields { return \@results; } +my $stylesheet; + sub XSLTParse4Display { my ($biblionumber,$xslfile) = @_; # grab the XML, run it through our stylesheet, push it out to the browser @@ -116,10 +118,12 @@ sub XSLTParse4Display { my $parser = XML::LibXML->new(); # don't die when you find &, >, etc $parser->recover_silently(1); - my $xslt = XML::LibXSLT->new(); my $source = $parser->parse_string($xmlrecord); - my $style_doc = $parser->parse_file($xslfile); - my $stylesheet = $xslt->parse_stylesheet($style_doc); + unless ( $stylesheet ) { + my $xslt = XML::LibXSLT->new(); + my $style_doc = $parser->parse_file($xslfile); + $stylesheet = $xslt->parse_stylesheet($style_doc); + } my $results = $stylesheet->transform($source); my $newxmlrecord = $stylesheet->output_string($results); return $newxmlrecord;