<?xml version='1.0'?>
+<!DOCTYPE stylesheet [<!ENTITY nbsp " " >]>
<xsl:stylesheet version="1.0" xmlns:marc="http://www.loc.gov/MARC21/slim" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template name="datafield">
<xsl:param name="tag"/>
<xsl:param name="delimeter"><xsl:text> </xsl:text></xsl:param>
<xsl:param name="subdivCodes"/>
<xsl:param name="subdivDelimiter"/>
+ <xsl:param name="prefix"/>
+ <xsl:param name="suffix"/>
<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:value-of select="$prefix"/><xsl:value-of select="text()"/><xsl:value-of select="$suffix"/><xsl:value-of select="$delimeter"/>
</xsl:if>
</xsl:for-each>
</xsl:variable>
<xsl:value-of select="substring($str,1,string-length($str)-string-length($delimeter))"/>
</xsl:template>
+ <xsl:template name="subfieldSelectSpan">
+ <xsl:param name="codes"/>
+ <xsl:param name="delimeter"><xsl:text> </xsl:text></xsl:param>
+ <xsl:param name="subdivCodes"/>
+ <xsl:param name="subdivDelimiter"/>
+ <xsl:param name="prefix"/>
+ <xsl:param name="suffix"/>
+ <xsl:for-each select="marc:subfield">
+ <xsl:if test="contains($codes, @code)">
+ <span>
+ <xsl:attribute name="class"><xsl:value-of select="@code"/></xsl:attribute>
+ <xsl:if test="contains($subdivCodes, @code)">
+ <xsl:value-of select="$subdivDelimiter"/>
+ </xsl:if>
+ <xsl:value-of select="$prefix"/><xsl:value-of select="text()"/><xsl:value-of select="$suffix"/><xsl:if test="position()!=last()"><xsl:value-of select="$delimeter"/></xsl:if>
+ </span>
+ </xsl:if>
+ </xsl:for-each>
+ </xsl:template>
+
<xsl:template name="buildSpaces">
<xsl:param name="spaces"/>
<xsl:param name="char"><xsl:text> </xsl:text></xsl:param>
<xsl:when test="not($chopString)"/>
<xsl:otherwise><xsl:value-of select="$chopString"/></xsl:otherwise>
</xsl:choose>
-<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,']})>','))))')"/>
+ <xsl:choose>
+ <xsl:when test="contains($tranW,')')">
+ <xsl:value-of select="normalize-space(translate(substring-after($tranW,')'),'[]{}()<>',''))"/>
+ </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
<xsl:variable name="code6" select="marc:subfield[@code=6]"/>
<xsl:if test="contains(string($basetags), substring($code6,1,3))">
<span>
- <xsl:if test="boolean($class)">
- <xsl:attribute name="class"><xsl:value-of select="$class"/></xsl:attribute>
- </xsl:if>
<xsl:choose>
- <!-- display right-to-left tags floating right of their left-to-right counterparts -->
- <xsl:when test="substring($code6,string-length($code6)-1,2) ='/r'">
- <xsl:attribute name="style">display:block; text-align:right; float:right; width:50%; padding-left:20px</xsl:attribute>
- <xsl:attribute name="dir">rtl</xsl:attribute>
- </xsl:when>
- <xsl:otherwise>
- <xsl:attribute name="style">display:block; </xsl:attribute>
- </xsl:otherwise>
+ <xsl:when test="boolean($class) and substring($code6,string-length($code6)-1,2) ='/r'">
+ <xsl:attribute name="class"><xsl:value-of select="$class"/> m880</xsl:attribute>
+ <xsl:attribute name="dir">rtl</xsl:attribute>
+ </xsl:when>
+ <xsl:when test="boolean($class)">
+ <xsl:attribute name="class"><xsl:value-of select="$class"/></xsl:attribute>
+ <xsl:attribute name="style">display:block; </xsl:attribute>
+ </xsl:when>
+ <xsl:when test="substring($code6,string-length($code6)-1,2) ='/r'">
+ <xsl:attribute name="class"><xsl:value-of select="$class"/> m880</xsl:attribute>
+ </xsl:when>
</xsl:choose>
<xsl:if test="boolean($label)">
<span class="label">
</xsl:if>
</xsl:for-each>
</xsl:variable>
- <xsl:choose>
- <xsl:when test="boolean($bibno)">
- <a>
- <xsl:attribute name="href">/cgi-bin/koha/opac-detail.pl?biblionumber=<xsl:value-of select="$bibno"/></xsl:attribute>
- <xsl:value-of select="$str"/>
- </a>
- </xsl:when>
- <xsl:when test="boolean($index) and boolean(marc:subfield[@code=9])">
- <a>
- <xsl:attribute name="href">/cgi-bin/koha/opac-search.pl?q=an:<xsl:value-of select="marc:subfield[@code=9]"/></xsl:attribute>
- <xsl:value-of select="$str"/>
- </a>
- </xsl:when>
- <xsl:when test="boolean($index)">
- <a>
- <xsl:attribute name="href">/cgi-bin/koha/opac-search.pl?q=<xsl:value-of select="$index"/>:<xsl:value-of select="marc:subfield[@code='a']"/></xsl:attribute>
+ <xsl:if test="string-length($str) > 0">
+ <xsl:choose>
+ <xsl:when test="boolean($bibno)">
+ <a>
+ <xsl:attribute name="href">/cgi-bin/koha/opac-detail.pl?biblionumber=<xsl:value-of select="$bibno"/></xsl:attribute>
+ <xsl:value-of select="$str"/>
+ </a>
+ </xsl:when>
+ <xsl:when test="boolean($index) and boolean(marc:subfield[@code=9])">
+ <a>
+ <xsl:attribute name="href">/cgi-bin/koha/opac-search.pl?q=an:<xsl:value-of select="marc:subfield[@code=9]"/></xsl:attribute>
+ <xsl:value-of select="$str"/>
+ </a>
+ </xsl:when>
+ <xsl:when test="boolean($index)">
+ <a>
+ <xsl:attribute name="href">/cgi-bin/koha/opac-search.pl?q=<xsl:value-of select="$index"/>:<xsl:value-of select="marc:subfield[@code='a']"/></xsl:attribute>
+ <xsl:value-of select="$str"/>
+ </a>
+ </xsl:when>
+ <xsl:otherwise>
<xsl:value-of select="$str"/>
- </a>
- </xsl:when>
- <xsl:otherwise>
- <xsl:value-of select="$str"/>
- </xsl:otherwise>
- </xsl:choose>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:if>
</span>
</xsl:if>
</xsl:for-each>