[Koha-patches] [PATCH] changes to OPAC results and detail XSLT

Galen Charlton galen.charlton at liblime.com
Wed Feb 25 20:29:40 CET 2009


Various changes to OPAC search results and bib
detail display for MARC21.

* Search results

[1] 245 subfields will be displayed in order $a, $b, $h, then
    rest of subfields in the order they appear in the record.
[2] New edition field from 250$a, displayed under author
[3] New other title field from 246$a$b, displayed under call number

* Bib details

[1] 245 subfields will be displayed in order $a, $b, $h, then
    rest of subfields in the order they appear in the record.
[2] New edition field from 250$a$b, displayed under publisher
[3] New description field from 300$a$b$c$e$g, under the edition.
[4] New other title field from the 246$i$a$b$h$f$g$n$p, above the
    uniform title field.
[6] All 6XX fields are displayed in the subjects field.
[7] '--' now separates subdivisions in subject headings.
---
 .../prog/en/xslt/MARC21slim2OPACDetail.xsl         |   71 ++++++++++++++-
 .../prog/en/xslt/MARC21slim2OPACResults.xsl        |   93 +++++++++-----------
 .../opac-tmpl/prog/en/xslt/MARC21slimUtils.xsl     |    7 ++-
 3 files changed, 113 insertions(+), 58 deletions(-)

diff --git a/koha-tmpl/opac-tmpl/prog/en/xslt/MARC21slim2OPACDetail.xsl b/koha-tmpl/opac-tmpl/prog/en/xslt/MARC21slim2OPACDetail.xsl
index b368886..34ff0c5 100644
--- a/koha-tmpl/opac-tmpl/prog/en/xslt/MARC21slim2OPACDetail.xsl
+++ b/koha-tmpl/opac-tmpl/prog/en/xslt/MARC21slim2OPACDetail.xsl
@@ -54,7 +54,22 @@
         <h1>
             <xsl:for-each select="marc:datafield[@tag=245]">
                     <xsl:call-template name="subfieldSelect">
-                        <xsl:with-param name="codes">abfghk</xsl:with-param>
+                        <xsl:with-param name="codes">a</xsl:with-param>
+                    </xsl:call-template>
+                    <xsl:if test="marc:subfield[@code='b']">
+                        <xsl:text> </xsl:text>
+                        <xsl:call-template name="subfieldSelect">
+                            <xsl:with-param name="codes">b</xsl:with-param>
+                        </xsl:call-template>
+                    </xsl:if>
+                    <xsl:if test="marc:subfield[@code='h']">
+                        <xsl:text> </xsl:text>
+                        <xsl:call-template name="subfieldSelect">
+                            <xsl:with-param name="codes">h</xsl:with-param>
+                        </xsl:call-template>
+                    </xsl:if>
+                    <xsl:call-template name="subfieldSelect">
+                        <xsl:with-param name="codes">fgknps</xsl:with-param>
                     </xsl:call-template>
             </xsl:for-each>
         </h1>
@@ -62,7 +77,6 @@
 
         <xsl:choose>
         <xsl:when test="marc:datafield[@tag=100] or marc:datafield[@tag=110] or marc:datafield[@tag=111] or marc:datafield[@tag=700] or marc:datafield[@tag=710] or marc:datafield[@tag=711]">
-
         <h5 class="author">by
         <xsl:for-each select="marc:datafield[@tag=100 or @tag=700]">
         <a>
@@ -169,7 +183,37 @@
             </xsl:for-each>
         </span> 
         </xsl:if>
-        <xsl:if test="marc:datafield[@tag=020]">
+        <xsl:if test="marc:datafield[@tag=250]">
+        <span class="results_summary"><span class="label">Edition: </span>
+            <xsl:for-each select="marc:datafield[@tag=250]">
+                <xsl:call-template name="chopPunctuation">
+                  <xsl:with-param name="chopString">
+                    <xsl:call-template name="subfieldSelect">
+                        <xsl:with-param name="codes">ab</xsl:with-param>
+                    </xsl:call-template>
+                   </xsl:with-param>
+               </xsl:call-template>
+                    <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=300]">
+        <span class="results_summary"><span class="label">Description: </span>
+            <xsl:for-each select="marc:datafield[@tag=300]">
+                <xsl:call-template name="chopPunctuation">
+                  <xsl:with-param name="chopString">
+                    <xsl:call-template name="subfieldSelect">
+                        <xsl:with-param name="codes">abceg</xsl:with-param>
+                    </xsl:call-template>
+                   </xsl:with-param>
+               </xsl:call-template>
+                    <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=020]">
         <span class="results_summary"><span class="label">ISBN: </span>
         <!-- unAPI <abbr/> tag -->
         <xsl:for-each select="marc:datafield[@tag=020]">
@@ -189,6 +233,21 @@
         </span>
         </xsl:if>
 
+        <xsl:if test="marc:datafield[@tag=246]">
+        <span class="results_summary"><span class="label">Other Title: </span>
+            <xsl:for-each select="marc:datafield[@tag=246]">
+                <xsl:call-template name="chopPunctuation">
+                  <xsl:with-param name="chopString">
+                    <xsl:call-template name="subfieldSelect">
+                        <xsl:with-param name="codes">iabhfgnp</xsl:with-param>
+                    </xsl:call-template>
+                   </xsl:with-param>
+               </xsl:call-template>
+                    <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=130]|marc:datafield[@tag=240]|marc:datafield[@tag=730][@ind2!=2]">
         <span class="results_summary"><span class="label">Uniform titles: </span>
         <xsl:for-each select="marc:datafield[@tag=130]|marc:datafield[@tag=240]|marc:datafield[@tag=730][@ind2!=2]">
@@ -211,9 +270,9 @@
         </span>
         </xsl:if>
 
-        <xsl:if test="marc:datafield[@tag=650]">
+        <xsl:if test="marc:datafield[substring(@tag, 1, 1) = '6']">
             <span class="results_summary"><span class="label">Related Subjects: </span>
-            <xsl:for-each select="marc:datafield[@tag=650]">
+            <xsl:for-each select="marc:datafield[substring(@tag, 1, 1) = '6']">
             <a>
             <xsl:choose>
             <xsl:when test="marc:subfield[@code=9]">
@@ -227,6 +286,8 @@
                 <xsl:with-param name="chopString">
                     <xsl:call-template name="subfieldSelect">
                         <xsl:with-param name="codes">abcdvxyz</xsl:with-param>
+                        <xsl:with-param name="subdivCodes">vxyz</xsl:with-param>
+                        <xsl:with-param name="subdivDelimiter">-- </xsl:with-param>
                     </xsl:call-template>
                 </xsl:with-param>
             </xsl:call-template>
diff --git a/koha-tmpl/opac-tmpl/prog/en/xslt/MARC21slim2OPACResults.xsl b/koha-tmpl/opac-tmpl/prog/en/xslt/MARC21slim2OPACResults.xsl
index 547453c..f217f69 100644
--- a/koha-tmpl/opac-tmpl/prog/en/xslt/MARC21slim2OPACResults.xsl
+++ b/koha-tmpl/opac-tmpl/prog/en/xslt/MARC21slim2OPACResults.xsl
@@ -377,19 +377,24 @@
         <xsl:if test="marc:datafield[@tag=245]">
         <xsl:for-each select="marc:datafield[@tag=245]">
             <xsl:variable name="title">
-                <xsl:choose>
-                <xsl:when test="marc:subfield[@code='b']">
-                    <xsl:call-template name="specialSubfieldSelect">
-                        <xsl:with-param name="axis">b</xsl:with-param>
-                        <xsl:with-param name="beforeCodes">afghk</xsl:with-param>
+                     <xsl:call-template name="subfieldSelect">
+                        <xsl:with-param name="codes">a</xsl:with-param>
                     </xsl:call-template>
-                </xsl:when>
-                <xsl:otherwise>
-                <xsl:call-template name="subfieldSelect">
-                    <xsl:with-param name="codes">abfgk</xsl:with-param>
-                </xsl:call-template>
-                </xsl:otherwise>
-                </xsl:choose>
+                    <xsl:if test="marc:subfield[@code='b']">
+                        <xsl:text> </xsl:text>
+                        <xsl:call-template name="subfieldSelect">
+                            <xsl:with-param name="codes">b</xsl:with-param>
+                        </xsl:call-template>
+                    </xsl:if>
+                    <xsl:if test="marc:subfield[@code='h']">
+                        <xsl:text> </xsl:text>
+                        <xsl:call-template name="subfieldSelect">
+                            <xsl:with-param name="codes">h</xsl:with-param>
+                        </xsl:call-template>
+                    </xsl:if>
+                    <xsl:call-template name="subfieldSelect">
+                        <xsl:with-param name="codes">fgknps</xsl:with-param>
+                     </xsl:call-template>
             </xsl:variable>
             <xsl:variable name="titleChop">
                 <xsl:call-template name="chopPunctuation">
@@ -399,20 +404,6 @@
                 </xsl:call-template>
             </xsl:variable>
             <xsl:value-of select="$titleChop"/>
-            <xsl:if test="marc:subfield[@code='b']">
-                <xsl:text> : </xsl:text>
-                <xsl:call-template name="chopPunctuation">
-                    <xsl:with-param name="chopString">
-                        <xsl:call-template name="specialSubfieldSelect">
-                            <xsl:with-param name="axis">b</xsl:with-param>
-                            <xsl:with-param name="anyCodes">b</xsl:with-param>
-                            <xsl:with-param name="afterCodes">afghk</xsl:with-param>
-                        </xsl:call-template>
-                    </xsl:with-param>
-                </xsl:call-template>
-            </xsl:if>
-            <xsl:choose><xsl:when test="position()=last()"><xsl:text>. </xsl:text></xsl:when><xsl:otherwise><xsl:text>; </xsl:text></xsl:otherwise></xsl:choose>
-            <xsl:call-template name="part"/>
         </xsl:for-each>
         </xsl:if>
     </a>
@@ -457,6 +448,18 @@
     </xsl:when>
     </xsl:choose>
     </p>
+
+    <xsl:if test="marc:datafield[@tag=250]">
+	<span class="results_summary">
+    <span class="label">Edition: </span>
+            <xsl:for-each select="marc:datafield[@tag=250]">
+                    <xsl:call-template name="subfieldSelect">
+                        <xsl:with-param name="codes">ab</xsl:with-param>
+                    </xsl:call-template>
+            </xsl:for-each>
+	</span>
+    </xsl:if>
+
     <span class="results_summary">
     <xsl:if test="$typeOf008">
         <span class="label">Type: </span>
@@ -805,6 +808,18 @@
 	</span>
     </xsl:if>
 
+    <xsl:if test="marc:datafield[@tag=246]">
+	<span class="results_summary">
+    <span class="label">Other title: </span>
+            <xsl:for-each select="marc:datafield[@tag=246]">
+                    <xsl:call-template name="subfieldSelect">
+                        <xsl:with-param name="codes">ab</xsl:with-param>
+                    </xsl:call-template>
+            </xsl:for-each>
+	</span>
+
+    </xsl:if>
+
     <span class="results_summary">
 			   <span class="label">Availability: </span>
 			        <xsl:choose>
@@ -1005,32 +1020,6 @@
         </xsl:if>
     </xsl:template>
 
-    <xsl:template name="part">
-        <xsl:variable name="partNumber">
-            <xsl:call-template name="specialSubfieldSelect">
-                <xsl:with-param name="axis">n</xsl:with-param>
-                <xsl:with-param name="anyCodes">n</xsl:with-param>
-                <xsl:with-param name="afterCodes">fghkdlmor</xsl:with-param>
-            </xsl:call-template>
-        </xsl:variable>
-        <xsl:variable name="partName">
-            <xsl:call-template name="specialSubfieldSelect">
-                <xsl:with-param name="axis">p</xsl:with-param>
-                <xsl:with-param name="anyCodes">p</xsl:with-param>
-                <xsl:with-param name="afterCodes">fghkdlmor</xsl:with-param>
-            </xsl:call-template>
-        </xsl:variable>
-        <xsl:if test="string-length(normalize-space($partNumber))">
-                <xsl:call-template name="chopPunctuation">
-                    <xsl:with-param name="chopString" select="$partNumber"/>
-                </xsl:call-template>
-        </xsl:if>
-        <xsl:if test="string-length(normalize-space($partName))">
-                <xsl:call-template name="chopPunctuation">
-                    <xsl:with-param name="chopString" select="$partName"/>
-                </xsl:call-template>
-        </xsl:if>
-    </xsl:template>
     <xsl:template name="chopBrackets">
         <xsl:param name="chopString"></xsl:param>
         <xsl:variable name="string">
diff --git a/koha-tmpl/opac-tmpl/prog/en/xslt/MARC21slimUtils.xsl b/koha-tmpl/opac-tmpl/prog/en/xslt/MARC21slimUtils.xsl
index acfe598..edd28c3 100644
--- a/koha-tmpl/opac-tmpl/prog/en/xslt/MARC21slimUtils.xsl
+++ b/koha-tmpl/opac-tmpl/prog/en/xslt/MARC21slimUtils.xsl
@@ -22,9 +22,14 @@
 	<xsl:template name="subfieldSelect">
 		<xsl:param name="codes"/>
 		<xsl:param name="delimeter"><xsl:text> </xsl:text></xsl:param>
+		<xsl:param name="subdivCodes"/>
+		<xsl:param name="subdivDelimiter"/>
 		<xsl:variable name="str">
 			<xsl:for-each select="marc:subfield">
 				<xsl:if test="contains($codes, @code)">
+                    <xsl:if test="contains($subdivCodes, @code)">
+                        <xsl:value-of select="$subdivDelimiter"/>
+                    </xsl:if>
 					<xsl:value-of select="text()"/><xsl:value-of select="$delimeter"/>
 				</xsl:if>
 			</xsl:for-each>
@@ -62,4 +67,4 @@
 <metaInformation>
 <scenarios/><MapperInfo srcSchemaPath="" srcSchemaRoot="" srcSchemaPathIsRelative="yes" srcSchemaInterpretAsXML="no" destSchemaPath="" destSchemaRoot="" destSchemaPathIsRelative="yes" destSchemaInterpretAsXML="no"/>
 </metaInformation>
--->
\ No newline at end of file
+-->
-- 
1.5.5.GIT



More information about the Koha-patches mailing list