[Koha] MARC21slim2OPACResults.xsl error when including wikipage link

Alvaro Cornejo cornejo.alvaro at gmail.com
Sat Sep 21 15:37:53 NZST 2024


Hi

I´m installing a new koha 24.05 on a new ubuntu 24.4 using a database from
our production server in koha 19.11 under ubuntu 18.4.

I´m trying to setup the author wikipedia link as per:
https://wiki.koha-community.org/wiki/JQuery_Library#Add_links_out_to_Wikipedia_for_authors

I´ve modified js in order to adapt to our needs and add a language config
and a second search link to wikidata.

In order to add an icon along the link to wikipedia/wikidada at the end of
author info I edited MARC21slim2OPACResults.xsl as this:

Line 522
Original:
<span class="byAuthor">by</span><xsl:text> </xsl:text>

New:
<span class="byAuthor">by</span> <span class="author" name="name">
<xsl:text> </xsl:text>

I also tried
<span class="byAuthor">by</span> <span class="author" name="name"/>
<xsl:text> </xsl:text>
<span class="byAuthor">by</span> <span class="author" name="name"></span>
<xsl:text> </xsl:text>

but still get a similar error.

In koha 19.11 this modification works fine, I got the author, its BD/DD
dates then the two icons (wikidata & wikipedia) including the search links
with the author name.Links do work well.
https://es.wikipedia.org/w/index.php?title=Special%3ASearch&search=C%C3%A9sar%20VALLEJO

However in koha 24.05 the search results does only show an empty table that
only includes the item cover page.
In the other two mods, I get the icons before author data but links do not
work. They do not include author names.
https://es.wikipedia.org/w/index.php?title=Special%3ASearch&search=%20

The errors I get in logs are:
/usr/share/koha/opac/htdocs/opac-tmpl/bootstrap/en/xslt/MARC21slim2OPACResults.xsl:675:
parser error : Opening and ending tag mismatch: when line 520 and choose
    </xsl:choose>
                 ^
/usr/share/koha/opac/htdocs/opac-tmpl/bootstrap/en/xslt/MARC21slim2OPACResults.xsl:1468:
parser error : Opening and ending tag mismatch: choose line 519 and template
    </xsl:template>
                   ^
/usr/share/koha/opac/htdocs/opac-tmpl/bootstrap/en/xslt/MARC21slim2OPACResults.xsl:1612:
parser error : Opening and ending tag mismatch: template line 19 and
stylesheet
</xsl:stylesheet>
                 ^
/usr/share/koha/opac/htdocs/opac-tmpl/bootstrap/en/xslt/MARC21slim2OPACResults.xsl:1613:
parser error : Premature end of data in tag stylesheet line 4

^
[2024/09/20 22:10:00] [WARN] XSLT::Base:
/usr/share/koha/opac/htdocs/opac-tmpl/bootstrap/en/xslt/MARC21slim2OPACResults.xsl:674:
parser error : Opening and ending tag mismatch: span line 522 and xsl:when
    </xsl:when>
               ^
/usr/share/koha/opac/htdocs/opac-tmpl/bootstrap/en/xslt/MARC21slim2OPACResults.xsl:675:
parser error : Opening and ending tag mismatch: when line 520 and choose
    </xsl:choose>
                 ^
/usr/share/koha/opac/htdocs/opac-tmpl/bootstrap/en/xslt/MARC21slim2OPACResults.xsl:1468:
parser error : Opening and ending tag mismatch: choose line 519 and template
    </xsl:template>
                   ^
/usr/share/koha/opac/htdocs/opac-tmpl/bootstrap/en/xslt/MARC21slim2OPACResults.xsl:1612:
parser error : Opening and ending tag mismatch: template line 19 and
stylesheet
</xsl:stylesheet>
                 ^
/usr/share/koha/opac/htdocs/opac-tmpl/bootstrap/en/xslt/MARC21slim2OPACResults.xsl:1613:
parser error : Premature end of data in tag stylesheet line 4

This is the modified js:

// MULTILINGUAL OK
// PARA OPAC MARC SEARCH RESULTS
// Se incluye segundo enlace a WIKIDATA
var names = $('span[name="name"');
for (var i=0; i < names.length; i++) {
        var name_string = $(names[i]).text(); // mostly surname, name
var myLang = $('html').attr('lang');
        var fs = (name_string+', ').split(', ');
        var H = new Array;
var W = new Array;
        if (myLang == "es-ES") {
        H.push('<span title="Busque este autor en Wikipedia">');
        H.push('<a target="_blank" href="
https://es.wikipedia.org/w/index.php?title=Special%3ASearch&search=');
        W.push('<span title="Busque este autor en Wikidata">');
        W.push('<a target="_blank" href="
https://www.wikidata.org/w/index.php?title=Special%3ASearch&profile=advanced&fulltext=1&ns0=1&ns120=1&search='
);
        }
if (myLang == "en") {
        H.push('<span title="Search this author in ES.Wikipedia">');
        H.push('<a target="_blank" href="
https://en.wikipedia.org/w/index.php?title=Special%3ASearch&search=');
        W.push('<span title="Search this author in Wikidata">');
        W.push('<a target="_blank" href="
https://www.wikidata.org/w/index.php?title=Special%3ASearch&profile=advanced&fulltext=1&ns0=1&ns120=1&search='
);
        }
        H.push(encodeURIComponent(fs[1]+' '+fs[0]));
        H.push('">  ');
        H.push('<picture><source type="image/webp"
srcset="/plugin/wikipedia-16.png">');
        H.push('<img
src="/plugin/wikipedia-16.png"/></picture></a>  ');
        H.push('</span>');
$(names[i]).after(H.join(''));
        W.push(encodeURIComponent(fs[1]+' '+fs[0]));
        W.push('">  ');
        W.push('<picture><source type="image/webp"
srcset="/plugin/Wikidatafavicon20x12.png"/>');
        W.push('<img
src="/plugin/Wikidatafavicon20x12.png"/></picture></a>  ');
        W.push('</span>');
        $(names[i]).after(W.join(''));
};

Regards,

Alvaro
|----------------------------------------------------------------------------------------|
 Stay safe / Cuídate/  Reste sécurisé
*7* Switch off as you go / Apaga lo que no usas /  Débranchez au fur et à
mesure.
 *q *Recycle always / Recicla siempre / Recyclez toujours
 P Print only if absolutely necessary / Imprime solo si es necesario /
Imprimez seulement si nécessaire


More information about the Koha mailing list