+ my $AuthorityXSLTResultsDisplay = C4::Context->preference('AuthorityXSLTResultsDisplay');
+ if ($results && $AuthorityXSLTResultsDisplay) {
+ my $lang = C4::Languages::getlanguage();
+ foreach my $result (@$results) {
+ my $authority = Koha::Authorities->find($result->{authid});
+ next unless $authority;
+
+ my $authtypecode = $authority->authtypecode;
+ my $xsl = $AuthorityXSLTResultsDisplay;
+ $xsl =~ s/\{langcode\}/$lang/g;
+ $xsl =~ s/\{authtypecode\}/$authtypecode/g;
+
+ my $xslt_engine = Koha::XSLT::Base->new;
+ my $output = $xslt_engine->transform({ xml => $authority->marcxml, file => $xsl });
+ if ($xslt_engine->err) {
+ warn "XSL transformation failed ($xsl): " . $xslt_engine->err;
+ next;
+ }
+
+ $result->{html} = $output;
+ }
+ }
+