Bug 20339: Unify MARC21 ISBN/ISSN handling in XSL
authorPasi Kallinen <pasi.kallinen@joensuu.fi>
Tue, 6 Mar 2018 09:59:28 +0000 (11:59 +0200)
committerNick Clemens <nick@bywatersolutions.com>
Fri, 22 Jun 2018 15:26:35 +0000 (15:26 +0000)
The code to show the ISBN and ISSN is repeated between the search results
and the detail view. Create a function to show the ISBN/ISSN, and call
that instead.

Test plan:
1) Apply patch
2) Search for any records, check that the ISBN and ISSN are shown
   correctly
3) Go to biblio detail pages, check that the ISBN and ISSN are shown
   correctly

Signed-off-by: Pasi Kallinen <pasi.kallinen@joensuu.fi>

Signed-off-by: claude <claude.brayer@cea.fr>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>

koha-tmpl/intranet-tmpl/prog/en/xslt/MARC21slim2intranetDetail.xsl
koha-tmpl/intranet-tmpl/prog/en/xslt/MARC21slim2intranetResults.xsl
koha-tmpl/intranet-tmpl/prog/en/xslt/MARC21slimUtils.xsl

index cf39ec4..885a8dc 100644 (file)
         </xsl:if>
 
 
-        <!-- Build ISBN -->
-        <xsl:if test="marc:datafield[@tag=020]/marc:subfield[@code='a']">
-          <span class="results_summary isbn"><span class="label">ISBN: </span>
-            <xsl:for-each select="marc:datafield[@tag=020]/marc:subfield[@code='a']">
-              <span property="isbn">
-                <xsl:value-of select="."/>
-                <xsl:choose>
-                  <xsl:when test="position()=last()">
-                    <xsl:text>.</xsl:text>
-                  </xsl:when>
-                  <xsl:otherwise>
-                    <xsl:text>; </xsl:text>
-                  </xsl:otherwise>
-                </xsl:choose>
-              </span>
-            </xsl:for-each>
-          </span>
-        </xsl:if>
-
-        <!-- Build ISSN -->
-        <xsl:if test="marc:datafield[@tag=022]/marc:subfield[@code='a']">
-          <span class="results_summary issn"><span class="label">ISSN: </span>
-            <xsl:for-each select="marc:datafield[@tag=022]/marc:subfield[@code='a']">
-              <span property="issn">
-                <xsl:value-of select="."/>
-                <xsl:choose>
-                  <xsl:when test="position()=last()">
-                    <xsl:text>.</xsl:text>
-                  </xsl:when>
-                  <xsl:otherwise>
-                    <xsl:text>; </xsl:text>
-                  </xsl:otherwise>
-                </xsl:choose>
-              </span>
-            </xsl:for-each>
-          </span>
-        </xsl:if>
+        <xsl:call-template name="showISBNISSN"/>
 
         <xsl:if test="marc:datafield[@tag=013]">
             <span class="results_summary patent_info">
index 3e508c0..4edc2f2 100644 (file)
     </span>
    </xsl:if>
 
-    <xsl:if test="marc:datafield[@tag=020]">
-    <span class="results_summary isbn"><span class="label">ISBN: </span>
-    <xsl:for-each select="marc:datafield[@tag=020]">
-    <xsl:variable name="isbn" select="marc:subfield[@code='a']"/>
-            <xsl:value-of select="marc:subfield[@code='a']"/>
-            <xsl:choose><xsl:when test="position()=last()"><xsl:text>.</xsl:text></xsl:when><xsl:otherwise><xsl:text>; </xsl:text></xsl:otherwise></xsl:choose>
-    </xsl:for-each>
-    </span>
-    </xsl:if>
-
-    <xsl:if test="marc:datafield[@tag=022]">
-    <span class="results_summary issn"><span class="label">ISSN: </span>
-    <xsl:for-each select="marc:datafield[@tag=022]">
-            <xsl:value-of select="marc:subfield[@code='a']"/>
-            <xsl:choose><xsl:when test="position()=last()"><xsl:text>.</xsl:text></xsl:when><xsl:otherwise><xsl:text>; </xsl:text></xsl:otherwise></xsl:choose>
-    </xsl:for-each>
-    </span>
-    </xsl:if>
+   <xsl:call-template name="showISBNISSN"/>
 
     <xsl:if test="marc:datafield[@tag=250]">
     <span class="results_summary edition">
index 192107b..a3db596 100644 (file)
         </span>
     </xsl:template>
 
+    <xsl:template name="showISBNISSN">
+      <xsl:call-template name="showSingleSubfield">
+        <xsl:with-param name="tag">020</xsl:with-param>
+        <xsl:with-param name="code">a</xsl:with-param>
+        <xsl:with-param name="class">isbn</xsl:with-param>
+        <xsl:with-param name="label">ISBN: </xsl:with-param>
+      </xsl:call-template>
+      <xsl:call-template name="showSingleSubfield">
+        <xsl:with-param name="tag">022</xsl:with-param>
+        <xsl:with-param name="code">a</xsl:with-param>
+        <xsl:with-param name="class">issn</xsl:with-param>
+        <xsl:with-param name="label">ISSN: </xsl:with-param>
+      </xsl:call-template>
+    </xsl:template>
+
+    <xsl:template name="showSingleSubfield">
+      <xsl:param name="tag"/>
+      <xsl:param name="code"/>
+      <xsl:param name="class"/>
+      <xsl:param name="label"/>
+      <xsl:if test="marc:datafield[@tag=$tag]/marc:subfield[@code=$code]">
+        <span><xsl:attribute name="class"><xsl:value-of select="concat('results_summary ', $class)"/></xsl:attribute>
+        <span class="label"><xsl:value-of select="$label"/></span>
+            <xsl:for-each select="marc:datafield[@tag=$tag]/marc:subfield[@code=$code]">
+              <span><xsl:attribute name="property"><xsl:value-of select="$class"/></xsl:attribute>
+                <xsl:value-of select="."/>
+                <xsl:choose>
+                  <xsl:when test="position()=last()">
+                    <xsl:text>.</xsl:text>
+                  </xsl:when>
+                  <xsl:otherwise>
+                    <xsl:text>; </xsl:text>
+                  </xsl:otherwise>
+                </xsl:choose>
+              </span>
+            </xsl:for-each>
+          </span>
+        </xsl:if>
+    </xsl:template>
+
 </xsl:stylesheet>
 
 <!-- Stylus Studio meta-information - (c)1998-2002 eXcelon Corp.