Bug 29556

Summary: MARC21slim2MODS.xsl broken by duplicate template name "part"
Product: Koha Reporter: Owen Leonard <oleonard>
Component: OPACAssignee: Owen Leonard <oleonard>
Status: CLOSED FIXED QA Contact: Marcel de Rooy <m.de.rooy>
Severity: normal    
Priority: P5 - low CC: andrew, david, fridolin.somers, jonathan.druart, kyle, m.de.rooy, victor
Version: Main   
Hardware: All   
OS: All   
See Also: https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=29629
Change sponsored?: --- Patch complexity: Trivial patch
Documentation contact: Documentation submission:
Text to go in the release notes:
This fixes an error when making an unAPI request in the OPAC using the MODS format. A 500 page error was displayed instead of an XML file. Example URL: http://your-library-opac-domain/cgi-bin/koha/unapi?id=koha:biblionumber:1&format=MODS
Version(s) released in:
22.05.00,21.11.01,21.05.08
Circulation function:
Bug Depends on: 5927    
Bug Blocks:    
Attachments: Bug 29556: MARC21slim2MODS.xsl broken by duplicate template name "part"
Bug 29556: MARC21slim2MODS.xsl broken by duplicate template name "part"
Bug 29556: MARC21slim2MODS.xsl broken by duplicate template name "part"

Description Owen Leonard 2021-11-22 14:55:18 UTC
Bug 5927, "Show series information in search results page" made a change to MARC21slimUtils.xsl, adding a block starting like this:

<xsl:template name="part">

...this breaks UNAPI in the OPAC when using MODS format because MARC21slim2MODS.xsl, which imports MARC21slimUtils.xsl, also includes the same block.

Removing the redundant section from MARC21slim2MODS.xsl should fix the error.
Comment 1 Owen Leonard 2021-11-22 15:03:37 UTC Comment hidden (obsolete)
Comment 2 David Nind 2021-11-25 18:57:46 UTC Comment hidden (obsolete)
Comment 3 Marcel de Rooy 2021-11-26 08:52:17 UTC
Resolves:
[2021/11/26 08:51:19] [WARN] XSLT::Base: compilation error: file /usr/share/koha/koha-tmpl/intranet-tmpl/prog/en/xslt/MARC21slim2MODS.xsl element template
xsl:template: error duplicate name 'part'
 at /usr/share/koha/Koha/XSLT/Base.pm line 342.
Comment 4 Marcel de Rooy 2021-11-26 08:53:11 UTC
Created attachment 128028 [details] [review]
Bug 29556: MARC21slim2MODS.xsl broken by duplicate template name "part"

This patch removes a redundant section from MARC21slim2MODS.xsl which
was breaking the option to use unAPI in the OPAC using MODS format.

To test, apply the patch and view a record in the OPAC using unAPI,
e.g.:

/cgi-bin/koha/unapi?id=koha:biblionumber:1&format=MODS

You should see an XML file where previously there would have been an
error.

Signed-off-by: David Nind <david@davidnind.com>

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Comment 5 Marcel de Rooy 2021-11-26 10:23:06 UTC
What about:

git grep 'xsl:template name="part"'                                                                                                                         [11:13:29]
koha-tmpl/intranet-tmpl/prog/en/xslt/MARC21slim2MADS.xsl:    <xsl:template name="part">
koha-tmpl/intranet-tmpl/prog/en/xslt/MARC21slim2MODS3-1.xsl:    <xsl:template name="part">
koha-tmpl/intranet-tmpl/prog/en/xslt/MARC21slim2MODS3.xsl:  <xsl:template name="part">
koha-tmpl/intranet-tmpl/prog/en/xslt/MARC21slim2MODS32.xsl: <xsl:template name="part">
koha-tmpl/intranet-tmpl/prog/en/xslt/MARC21slimUtils.xsl:    <xsl:template name="part">
koha-tmpl/intranet-tmpl/prog/en/xslt/UNIMARCslim2intranetDetail.xsl:    <xsl:template name="part">
koha-tmpl/opac-tmpl/bootstrap/en/xslt/MARC21slimUtils.xsl:    <xsl:template name="part">
koha-tmpl/opac-tmpl/bootstrap/en/xslt/UNIMARCslim2OPACDetail.xsl:    <xsl:template name="part">

% grep slimUtils koha-tmpl/intranet-tmpl/prog/en/xslt/MARC21slim2MADS.xsl koha-tmpl/intranet-tmpl/prog/en/xslt/MARC21slim2MODS3-1.xsl koha-tmpl/intranet-tmpl/prog/en/xslt/MARC21slim2MODS3.xsl koha-tmpl/intranet-tmpl/prog/en/xslt/MARC21slim2MODS32.xsl koha-tmpl/intranet-tmpl/prog/en/xslt/MARC21slimUtils.xsl koha-tmpl/intranet-tmpl/prog/en/xslt/UNIMARCslim2intranetDetail.xsl koha-tmpl/opac-tmpl/bootstrap/en/xslt/MARC21slimUtils.xsl koha-tmpl/opac-tmpl/bootstrap/en/xslt/UNIMARCslim2OPACDetail.xsl
koha-tmpl/intranet-tmpl/prog/en/xslt/MARC21slim2MADS.xsl:    <xsl:include href="http://www.loc.gov/marcxml/xslt/MARC21slimUtils.xsl"/>
koha-tmpl/intranet-tmpl/prog/en/xslt/MARC21slim2MODS3-1.xsl:    <xsl:include href="MARC21slimUtils-MODS31.xsl"/>
koha-tmpl/intranet-tmpl/prog/en/xslt/MARC21slim2MODS3.xsl:      <xsl:include href="MARC21slimUtils.xsl"/>
koha-tmpl/intranet-tmpl/prog/en/xslt/MARC21slim2MODS32.xsl:     <xsl:include href="MARC21slimUtils.xsl"/>
koha-tmpl/intranet-tmpl/prog/en/xslt/UNIMARCslim2intranetDetail.xsl:<xsl:import href="UNIMARCslimUtils.xsl"/>
koha-tmpl/opac-tmpl/bootstrap/en/xslt/UNIMARCslim2OPACDetail.xsl:<xsl:import href="UNIMARCslimUtils.xsl"/>
Comment 6 Owen Leonard 2021-11-30 12:19:30 UTC
> koha-tmpl/intranet-tmpl/prog/en/xslt/MARC21slim2MADS.xsl

This seems to be an authority record export format which can be tested by viewing an authority in the staff interface and choosing Save -> MADS. The export appears to work correctly.

> koha-tmpl/intranet-tmpl/prog/en/xslt/MARC21slim2MODS3-1.xsl

This seems to be a bibliographic record export format which can be tested by viewing a bibliographic record in the staff interface and choosing Save -> MODS. The export appears to work correctly.

> koha-tmpl/intranet-tmpl/prog/en/xslt/MARC21slim2MODS3.xsl
> koha-tmpl/intranet-tmpl/prog/en/xslt/MARC21slim2MODS32.xsl

These two files appear to be unused. I could only find references to them in .po files.
Comment 7 Fridolin Somers 2021-12-03 06:57:24 UTC
Pushed to master for 22.05, thanks to everybody involved!
Comment 8 Marcel de Rooy 2021-12-03 08:06:41 UTC
Jonathan:

Here is what makes the difference (yes it is confusing at least):

MARC21slim2MODS.xsl contains
   <xsl:include href="MARC21slimUtils.xsl"/>
This is our include that contains the template named part.

But MARC21slim2MADS.xsl contains
    <xsl:include href="http://www.loc.gov/marcxml/xslt/MARC21slimUtils.xsl"/>
This is NOT our include, but the LOC one.
And it does not include a template named part.

Etc.
Comment 9 Marcel de Rooy 2021-12-03 08:07:02 UTC
(In reply to Owen Leonard from comment #6)
> > koha-tmpl/intranet-tmpl/prog/en/xslt/MARC21slim2MADS.xsl
> 
> This seems to be an authority record export format which can be tested by
> viewing an authority in the staff interface and choosing Save -> MADS. The
> export appears to work correctly.
> 
> > koha-tmpl/intranet-tmpl/prog/en/xslt/MARC21slim2MODS3-1.xsl
> 
> This seems to be a bibliographic record export format which can be tested by
> viewing a bibliographic record in the staff interface and choosing Save ->
> MODS. The export appears to work correctly.
> 
> > koha-tmpl/intranet-tmpl/prog/en/xslt/MARC21slim2MODS3.xsl
> > koha-tmpl/intranet-tmpl/prog/en/xslt/MARC21slim2MODS32.xsl
> 
> These two files appear to be unused. I could only find references to them in
> .po files.

Thanks for checking. See former comment too.
Comment 10 Marcel de Rooy 2021-12-03 08:09:00 UTC
What does not help either, is that opac/unapi runs INTRANET xslt sheets:

sub get_xslt_file {
    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('intrahtdocs') .
                    "/prog/en/xslt/" .
                    $format_to_stylesheet_map->{$marcflavour}->{$format};
Comment 11 Marcel de Rooy 2021-12-03 08:12:11 UTC
(In reply to Owen Leonard from comment #6)
> > koha-tmpl/intranet-tmpl/prog/en/xslt/MARC21slim2MODS3.xsl
> > koha-tmpl/intranet-tmpl/prog/en/xslt/MARC21slim2MODS32.xsl
> 
> These two files appear to be unused. I could only find references to them in
> .po files.

Lets remove them on bug 29629.
Comment 12 Kyle M Hall (khall) 2021-12-03 15:18:22 UTC
Pushed to 21.11.x for 21.11.01
Comment 13 Andrew Fuerste-Henry 2021-12-17 19:17:15 UTC
Pushed to 21.05.x for 21.05.08
Comment 14 Victor Grousset/tuxayo 2021-12-22 21:36:46 UTC
Not backported to oldoldstable (20.11.x). Feel free to ask if it's needed.