5622: Improve display of MARC21 773 field in XSLT detail view
authorMarcel de Rooy <m.de.rooy@rijksmuseum.nl>
Thu, 17 Mar 2011 14:22:43 +0000 (10:22 -0400)
committerChris Cormack <chrisc@catalyst.net.nz>
Thu, 17 Mar 2011 22:05:11 +0000 (11:05 +1300)
Applies change to OPAC and staff detail view.
Chops punctuation. Adds 773g. Strips MARC org code from URL.
Utils code is used as basis for patches #5662 and #5663 too.

Signed-off-by: Jared Camins-Esakov <jcamins@bywatersolutions.com>
Signed-off-by: Chris Cormack <chrisc@catalyst.net.nz>
koha-tmpl/intranet-tmpl/prog/en/xslt/MARC21slim2intranetDetail.xsl
koha-tmpl/intranet-tmpl/prog/en/xslt/MARC21slimUtils.xsl
koha-tmpl/opac-tmpl/prog/en/xslt/MARC21slim2OPACDetail.xsl
koha-tmpl/opac-tmpl/prog/en/xslt/MARC21slimUtils.xsl

index 5320c40..3072ce0 100644 (file)
         </xsl:choose>
         </span>
                 <xsl:variable name="f773">
-                    <xsl:call-template name="subfieldSelect">
+                    <xsl:call-template name="chopPunctuation"><xsl:with-param name="chopString"><xsl:call-template name="subfieldSelect">
                         <xsl:with-param name="codes">at</xsl:with-param>
-                    </xsl:call-template>
+                    </xsl:call-template></xsl:with-param></xsl:call-template>
                 </xsl:variable>
             <xsl:choose>
                 <xsl:when test="$UseControlNumber = '1' and marc:subfield[@code='w']">
-                    <a href="/cgi-bin/koha/catalogue/search.pl?q=Control-number:{marc:subfield[@code='w']}">
-                        <xsl:value-of select="translate($f773, '()', '')"/>
+                    <a><xsl:attribute name="href">/cgi-bin/koha/catalogue/search.pl?q=Control-number:<xsl:call-template name="extractControlNumber"><xsl:with-param name="subfieldW" select="marc:subfield[@code='w']"/></xsl:call-template></xsl:attribute>
+                        <xsl:value-of select="translate($f773, '()', '')"/><xsl:if test="marc:subfield[@code='g']"><xsl:text> </xsl:text><xsl:value-of select="marc:subfield[@code='g']"/></xsl:if>
                     </a>
                 </xsl:when>
                 <xsl:otherwise>
                     <a><xsl:attribute name="href">/cgi-bin/koha/catalogue/search.pl?q=Title:<xsl:value-of select="translate($f773, '()', '')"/></xsl:attribute>
-                        <xsl:value-of select="$f773"/>
+                        <xsl:value-of select="$f773"/><xsl:if test="marc:subfield[@code='g']"><xsl:text> </xsl:text><xsl:value-of select="marc:subfield[@code='g']"/></xsl:if>
                     </a>
                 </xsl:otherwise>
             </xsl:choose>
index 43f86b0..0cd4559 100644 (file)
 <xsl:text> </xsl:text>
        </xsl:template>
 
+       <!-- Function extractControlNumber is used to extract the control number (record number) from MARC tags 773/80/85 [etc.] subfield $w.
+            Parameter: control number string.
+            Assumes LOC convention: (OrgCode)recordNumber.
+            If OrgCode is not present, return full string.
+            Additionally, handle various brackets/parentheses. Chop leading and trailing spaces.
+       -->
+       <xsl:template name="extractControlNumber">
+           <xsl:param name="subfieldW"/>
+           <xsl:variable name="tranW" select="translate($subfieldW,']})&gt;','))))')"/>
+           <xsl:choose>
+             <xsl:when test="contains($tranW,')')">
+               <xsl:value-of select="normalize-space(translate(substring-after($tranW,')'),'[]{}()&lt;&gt;',''))"/>
+             </xsl:when>
+             <xsl:otherwise>
+               <xsl:value-of select="normalize-space($subfieldW)"/>
+             </xsl:otherwise>
+           </xsl:choose>
+       </xsl:template>
 
     <!-- Function m880Select:  Display Alternate Graphic Representation (MARC 880) for selected latin "base"tags
         - should be called immediately before the corresonding latin tags are processed 
index cc88220..b5e60b9 100755 (executable)
         </xsl:choose>
         </span>
                 <xsl:variable name="f773">
-                    <xsl:call-template name="subfieldSelect">
+                    <xsl:call-template name="chopPunctuation"><xsl:with-param name="chopString"><xsl:call-template name="subfieldSelect">
                         <xsl:with-param name="codes">at</xsl:with-param>
-                    </xsl:call-template>
+                    </xsl:call-template></xsl:with-param></xsl:call-template>
                 </xsl:variable>
             <xsl:choose>
                 <xsl:when test="$UseControlNumber = '1' and marc:subfield[@code='w']">
-                    <a href="/cgi-bin/koha/opac-search.pl?q=Control-number:{marc:subfield[@code='w']}">
-                        <xsl:value-of select="translate($f773, '()', '')"/>
+                    <a><xsl:attribute name="href">/cgi-bin/koha/opac-search.pl?q=Control-number:<xsl:call-template name="extractControlNumber"><xsl:with-param name="subfieldW" select="marc:subfield[@code='w']"/></xsl:call-template></xsl:attribute>
+                        <xsl:value-of select="translate($f773, '()', '')"/><xsl:if test="marc:subfield[@code='g']"><xsl:text> </xsl:text><xsl:value-of select="marc:subfield[@code='g']"/></xsl:if>
                     </a>
                 </xsl:when>
                 <xsl:otherwise>
                     <a><xsl:attribute name="href">/cgi-bin/koha/opac-search.pl?q=Title:<xsl:value-of select="translate($f773, '()', '')"/></xsl:attribute>
-                        <xsl:value-of select="$f773"/>
+                        <xsl:value-of select="$f773"/><xsl:if test="marc:subfield[@code='g']"><xsl:text> </xsl:text><xsl:value-of select="marc:subfield[@code='g']"/></xsl:if>
                     </a>
                 </xsl:otherwise>
             </xsl:choose>
index d101723..559de13 100644 (file)
 <xsl:text> </xsl:text>
        </xsl:template>
 
+       <!-- Function extractControlNumber is used to extract the control number (record number) from MARC tags 773/80/85 [etc.] subfield $w.
+            Parameter: control number string.
+            Assumes LOC convention: (OrgCode)recordNumber.
+            If OrgCode is not present, return full string.
+            Additionally, handle various brackets/parentheses. Chop leading and trailing spaces.
+       -->
+       <xsl:template name="extractControlNumber">
+           <xsl:param name="subfieldW"/>
+           <xsl:variable name="tranW" select="translate($subfieldW,']})&gt;','))))')"/>
+           <xsl:choose>
+             <xsl:when test="contains($tranW,')')">
+               <xsl:value-of select="normalize-space(translate(substring-after($tranW,')'),'[]{}()&lt;&gt;',''))"/>
+             </xsl:when>
+             <xsl:otherwise>
+               <xsl:value-of select="normalize-space($subfieldW)"/>
+             </xsl:otherwise>
+           </xsl:choose>
+       </xsl:template>
 
     <!-- Function m880Select:  Display Alternate Graphic Representation (MARC 880) for selected latin "base"tags
         - should be called immediately before the corresonding latin tags are processed