From 84beea6a6ae1e1eaab5aefe9891aa95f636a0ead Mon Sep 17 00:00:00 2001
From: Tomas Cohen Arazi <tomascohen@theke.io>
Date: Fri, 7 Jan 2022 10:44:30 -0300
Subject: [PATCH] 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>
---
 etc/zebradb/xsl/koha-indexdefs-to-zebra.xsl | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/etc/zebradb/xsl/koha-indexdefs-to-zebra.xsl b/etc/zebradb/xsl/koha-indexdefs-to-zebra.xsl
index 6c40025bc6..f20c48871f 100644
--- a/etc/zebradb/xsl/koha-indexdefs-to-zebra.xsl
+++ b/etc/zebradb/xsl/koha-indexdefs-to-zebra.xsl
@@ -19,7 +19,7 @@
     <xsl:key name="index_data_field_tag"    match="kohaidx:index_data_field"    use="@tag"/>
     <xsl:key name="index_heading_conditional_tag" match="kohaidx:index_heading_conditional" use="@tag"/>
     <xsl:key name="index_match_heading_tag" match="kohaidx:index_match_heading" use="@tag"/>
-    <xsl:key name="index_sort_title_tag"          match="kohaidx:index_sort_title" use="@tag"/>
+    <xsl:key name="index_sort_title_tag"    match="kohaidx:index_sort_title"    use="@tag"/>
 
     <xsl:template match="kohaidx:index_defs">
     <xsl:comment>
@@ -40,7 +40,9 @@ definition file (probably something like {biblio,authority}-koha-indexdefs.xml)
             <xslo:template match="text()" mode="index_heading_conditional"/>
             <xslo:template match="text()" mode="index_match_heading"/>
             <xslo:template match="text()" mode="index_subject_thesaurus"/>
+        <xsl:if test="//kohaidx:index_sort_title">
             <xslo:template match="text()" mode="index_sort_title"/>
+        </xsl:if>
             <xslo:template match="/">
                 <xslo:if test="marc:collection">
                     <collection>
@@ -67,7 +69,9 @@ 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"/>
+                <xsl:if test="//kohaidx:index_sort_title">
                     <xslo:apply-templates mode="index_sort_title"/>
+                </xsl:if>
                 </z:record>
             </xslo:template>
 
-- 
2.34.1