Bug 18540 - koha-indexdefs-to-zebra.xsl introduces MARC21 stuff into UNIMARC xslts
Summary: koha-indexdefs-to-zebra.xsl introduces MARC21 stuff into UNIMARC xslts
Status: CLOSED FIXED
Alias: None
Product: Koha
Classification: Unclassified
Component: Architecture, internals, and plumbing (show other bugs)
Version: Main
Hardware: All All
: P5 - low normal
Assignee: Nick Clemens (kidclamp)
QA Contact: Tomás Cohen Arazi (tcohen)
URL:
Keywords:
Depends on: 14332
Blocks:
  Show dependency treegraph
 
Reported: 2017-05-04 14:21 UTC by Tomás Cohen Arazi (tcohen)
Modified: 2022-12-12 21:24 UTC (History)
6 users (show)

See Also:
Change sponsored?: ---
Patch complexity: Small patch
Documentation contact:
Documentation submission:
Text to go in the release notes:
Version(s) released in:
22.05.00,21.11.03,21.05.11
Circulation function:


Attachments
Bug 18540: Handle indexing sort title only when needed (6.88 KB, patch)
2021-05-13 16:47 UTC, Nick Clemens (kidclamp)
Details | Diff | Splinter Review
Bug 18540: Handle indexing sort title only when needed (6.92 KB, patch)
2021-12-20 01:10 UTC, Hayley Pelham
Details | Diff | Splinter Review
Bug 18540: Handle indexing sort title only when needed (6.98 KB, patch)
2022-01-07 13:58 UTC, Tomás Cohen Arazi (tcohen)
Details | Diff | Splinter Review
Bug 18540: (QA follow-up) Only mention index_sort_title if defined (2.46 KB, patch)
2022-01-07 13:58 UTC, Tomás Cohen Arazi (tcohen)
Details | Diff | Splinter Review
Bug 18540: Update MARC21 biblio XSL file (2.92 KB, patch)
2022-01-07 13:58 UTC, Tomás Cohen Arazi (tcohen)
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Tomás Cohen Arazi (tcohen) 2017-05-04 14:21:05 UTC
Bug 14332 introduced troubles because the koha-indexdefs-to-zebra.xsl is by no means MARC21-only or even biblio-only.

To reproduce:
- On current master, run:
  $ xsltproc etc/zebradb/xsl/koha-indexdefs-to-zebra.xsl etc/zebradb/marc_defs/unimarc/biblios/biblio-koha-indexdefs.xml > etc/zebradb/marc_defs/unimarc/biblios/biblio-zebra-indexdefs.xsl
- Run:
  $ git diff
=> FAIL: The following is added to etc/zebradb/marc_defs/unimarc/biblios/biblio-zebra-indexdefs.xsl, thus UNIMARC field 245 is being sent to the Title index

@@ -42,6 +43,7 @@ definition file (probably something like {biblio,authority}-koha-indexdefs.xml)
       <xslo:apply-templates mode="index_match_heading"/>
       <xslo:apply-templates mode="index_subject_thesaurus"/>
       <xslo:apply-templates mode="index_all"/>
+      <xslo:apply-templates mode="index_sort_tit"/>
     </z:record>
   </xslo:template>
   <xslo:template match="marc:controlfield[@tag='001']">
@@ -2681,6 +2683,19 @@ definition file (probably something like {biblio,authority}-koha-indexdefs.xml)
       <xslo:value-of select="."/>
     </z:index>
   </xslo:template>
+  <xslo:template mode="index_sort_tit" match="marc:datafield[@tag='245']">
+    <xslo:variable name="chop">
+      <xslo:choose>
+        <xslo:when test="not(number(@ind2))">0</xslo:when>
+        <xslo:otherwise>
+          <xslo:value-of select="number(@ind2)"/>
+        </xslo:otherwise>
+      </xslo:choose>
+    </xslo:variable>
+    <z:index name="Title:s">
+      <xslo:value-of select="substring(marc:subfield[@code='a'], $chop+1)"/>
+    </z:index>
+  </xslo:template>
Comment 1 Fridolin Somers 2020-12-22 10:48:15 UTC
+1

Very strange to see hardcoded field 245
Comment 2 Nick Clemens (kidclamp) 2021-05-13 16:47:59 UTC
Created attachment 120943 [details] [review]
Bug 18540: Handle indexing sort title only when needed

This patch moves the code that generates the xsl for MARC21 biblio sorting
to it's own template that is only called when specified in the xml

To test:
 1 - xsltproc etc/zebradb/xsl/koha-indexdefs-to-zebra.xsl etc/zebradb/marc_defs/marc21/authorities/authority-koha-indexdefs.xml > etc/zebradb/marc_defs/marc21/authorities/authority-zebra-indexdefs.xsl
 2 - git diff
 3 - Note that authority-zebra-indexdefs.xsl now has 245 Title:s info
 4 - Apply patch
 5 - xsltproc etc/zebradb/xsl/koha-indexdefs-to-zebra.xsl etc/zebradb/marc_defs/marc21/authorities/authority-koha-indexdefs.xml > etc/zebradb/marc_defs/marc21/authorities/authority-zebra-indexdefs.xsl
 6 - git diff
 7 - There are lines added about title sort, but no 245 block
 8 - xsltproc etc/zebradb/xsl/koha-indexdefs-to-zebra.xsl etc/zebradb/marc_defs/marc21/biblios/biblio-koha-indexdefs.xml > etc/zebradb/marc_defs/marc21/biblios/biblio-zebra-indexdefs.xsl
 9 - git diff
10 - Note lines changes to ...title_sort
11 - 245 block does not change
Comment 3 Hayley Pelham 2021-12-20 01:10:14 UTC
Created attachment 128724 [details] [review]
Bug 18540: Handle indexing sort title only when needed

This patch moves the code that generates the xsl for MARC21 biblio sorting
to it's own template that is only called when specified in the xml

To test:
 1 - xsltproc etc/zebradb/xsl/koha-indexdefs-to-zebra.xsl etc/zebradb/marc_defs/marc21/authorities/authority-koha-indexdefs.xml > etc/zebradb/marc_defs/marc21/authorities/authority-zebra-indexdefs.xsl
 2 - git diff
 3 - Note that authority-zebra-indexdefs.xsl now has 245 Title:s info
 4 - Apply patch
 5 - xsltproc etc/zebradb/xsl/koha-indexdefs-to-zebra.xsl etc/zebradb/marc_defs/marc21/authorities/authority-koha-indexdefs.xml > etc/zebradb/marc_defs/marc21/authorities/authority-zebra-indexdefs.xsl
 6 - git diff
 7 - There are lines added about title sort, but no 245 block
 8 - xsltproc etc/zebradb/xsl/koha-indexdefs-to-zebra.xsl etc/zebradb/marc_defs/marc21/biblios/biblio-koha-indexdefs.xml > etc/zebradb/marc_defs/marc21/biblios/biblio-zebra-indexdefs.xsl
 9 - git diff
10 - Note lines changes to ...title_sort
11 - 245 block does not change

Signed-off-by: Hayley Pelham <hayleypelham@catalyst.net.nz>
Comment 4 Tomás Cohen Arazi (tcohen) 2022-01-07 13:58:13 UTC
Created attachment 129165 [details] [review]
Bug 18540: Handle indexing sort title only when needed

This patch moves the code that generates the xsl for MARC21 biblio sorting
to it's own template that is only called when specified in the xml

To test:
 1 - xsltproc etc/zebradb/xsl/koha-indexdefs-to-zebra.xsl etc/zebradb/marc_defs/marc21/authorities/authority-koha-indexdefs.xml > etc/zebradb/marc_defs/marc21/authorities/authority-zebra-indexdefs.xsl
 2 - git diff
 3 - Note that authority-zebra-indexdefs.xsl now has 245 Title:s info
 4 - Apply patch
 5 - xsltproc etc/zebradb/xsl/koha-indexdefs-to-zebra.xsl etc/zebradb/marc_defs/marc21/authorities/authority-koha-indexdefs.xml > etc/zebradb/marc_defs/marc21/authorities/authority-zebra-indexdefs.xsl
 6 - git diff
 7 - There are lines added about title sort, but no 245 block
 8 - xsltproc etc/zebradb/xsl/koha-indexdefs-to-zebra.xsl etc/zebradb/marc_defs/marc21/biblios/biblio-koha-indexdefs.xml > etc/zebradb/marc_defs/marc21/biblios/biblio-zebra-indexdefs.xsl
 9 - git diff
10 - Note lines changes to ...title_sort
11 - 245 block does not change

Signed-off-by: Hayley Pelham <hayleypelham@catalyst.net.nz>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Comment 5 Tomás Cohen Arazi (tcohen) 2022-01-07 13:58:17 UTC
Created attachment 129166 [details] [review]
Bug 18540: (QA follow-up) Only mention index_sort_title if defined

This patch makes the generated xslt not mention index_sort_title unless
the entry is defined on the xml file. Otherwise there's a call to

<xslo:apply-templates mode="index_sort_title"/>

Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Comment 6 Tomás Cohen Arazi (tcohen) 2022-01-07 13:58:21 UTC
Created attachment 129167 [details] [review]
Bug 18540: Update MARC21 biblio XSL file

I ran the xsltproc on both MARC21 and UNIMARC files (biblios and
authorities). With my follow-up the only changed one is this one.

I skipped NORMARC as it is supposed to be removed by now (so unused in
Norway).

Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Comment 7 Fridolin Somers 2022-01-19 07:20:37 UTC
Pushed to master for 22.05, thanks to everybody involved ﷐[U+1F984]﷑
Comment 8 Kyle M Hall (khall) 2022-02-07 11:17:02 UTC
Pushed to 21.11.x for 21.11.03
Comment 9 Andrew Fuerste-Henry 2022-02-11 18:50:12 UTC
Pushed to 21.05.x for 21.05.11
Comment 10 Victor Grousset/tuxayo 2022-02-20 17:26:13 UTC
Not backported to oldoldstable (20.11.x). Feel free to ask if it's needed.