Koha/koha-tmpl/opac-tmpl/prog/en/xslt/UNIMARCslim2OPACResults.xsl
2011-04-10 20:38:30 +12:00

212 lines
9.5 KiB
XML

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE stylesheet [<!ENTITY nbsp "&#160;" >]>
<xsl:stylesheet version="1.0"
xmlns:marc="http://www.loc.gov/MARC21/slim"
xmlns:items="http://www.koha-community.org/items"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
exclude-result-prefixes="marc items">
<xsl:import href="UNIMARCslimUtils.xsl"/>
<xsl:output method = "xml" indent="yes" omit-xml-declaration = "yes" />
<xsl:key name="item-by-status" match="items:item" use="items:status"/>
<xsl:key name="item-by-status-and-branch" match="items:item" use="concat(items:status, ' ', items:homebranch)"/>
<xsl:template match="/">
<xsl:apply-templates/>
</xsl:template>
<xsl:template match="marc:record">
<xsl:variable name="Show856uAsImage" select="marc:sysprefs/marc:syspref[@name='OPACDisplay856uAsImage']"/>
<xsl:variable name="leader" select="marc:leader"/>
<xsl:variable name="leader6" select="substring($leader,7,1)"/>
<xsl:variable name="leader7" select="substring($leader,8,1)"/>
<xsl:variable name="biblionumber"
select="marc:datafield[@tag=090]/marc:subfield[@code='a']"/>
<xsl:variable name="isbn"
select="marc:datafield[@tag=010]/marc:subfield[@code='a']"/>
<xsl:variable name="hidelostitems" select="marc:sysprefs/marc:syspref[@name='hidelostitems']"/>
<xsl:if test="marc:datafield[@tag=200]">
<xsl:for-each select="marc:datafield[@tag=200]">
<xsl:variable name="title" select="marc:subfield[@code='a']"/>
<xsl:variable name="ntitle"
select="translate($title, '&#x0098;&#x009C;','')"/>
<div>
<xsl:call-template name="addClassRtl" />
<span class="results_summary">
<span class="label"/>
<a>
<xsl:attribute name="href">/cgi-bin/koha/opac-detail.pl?biblionumber=<xsl:value-of select="$biblionumber"/></xsl:attribute>
<xsl:value-of select="$ntitle" />
</a>
<xsl:if test="marc:subfield[@code='e']">
<xsl:text> : </xsl:text>
<xsl:for-each select="marc:subfield[@code='e']">
<xsl:value-of select="."/>
</xsl:for-each>
</xsl:if>
<xsl:if test="marc:subfield[@code='b']">
<xsl:text> [</xsl:text>
<xsl:value-of select="marc:subfield[@code='b']"/>
<xsl:text>]</xsl:text>
</xsl:if>
<xsl:if test="marc:subfield[@code='f']">
<xsl:text> / </xsl:text>
<xsl:value-of select="marc:subfield[@code='f']"/>
</xsl:if>
<xsl:if test="marc:subfield[@code='g']">
<xsl:text> ; </xsl:text>
<xsl:value-of select="marc:subfield[@code='g']"/>
</xsl:if>
</span>
</div>
</xsl:for-each>
</xsl:if>
<xsl:call-template name="tag_4xx" />
<xsl:call-template name="tag_210" />
<xsl:call-template name="tag_215" />
<span class="results_summary">
<span class="label">Availability: </span>
<xsl:choose>
<xsl:when test="marc:datafield[@tag=856]">
<xsl:for-each select="marc:datafield[@tag=856]">
<xsl:variable name="SubqText"><xsl:value-of select="marc:subfield[@code='q']"/></xsl:variable>
<xsl:choose>
<xsl:when test="@ind2=0">
<a>
<xsl:attribute name="href">
<xsl:value-of select="marc:subfield[@code='u']"/>
</xsl:attribute>
<xsl:choose>
<xsl:when test="($Show856uAsImage='Results' or $Show856uAsImage='Both') and (substring($SubqText,1,6)='image/' or $SubqText='img' or $SubqText='bmp' or $SubqText='cod' or $SubqText='gif' or $SubqText='ief' or $SubqText='jpe' or $SubqText='jpeg' or $SubqText='jpg' or $SubqText='jfif' or $SubqText='png' or $SubqText='svg' or $SubqText='tif' or $SubqText='tiff' or $SubqText='ras' or $SubqText='cmx' or $SubqText='ico' or $SubqText='pnm' or $SubqText='pbm' or $SubqText='pgm' or $SubqText='ppm' or $SubqText='rgb' or $SubqText='xbm' or $SubqText='xpm' or $SubqText='xwd')">
<xsl:element name="img"><xsl:attribute name="src"><xsl:value-of select="marc:subfield[@code='u']"/></xsl:attribute><xsl:attribute name="alt"><xsl:value-of select="marc:subfield[@code='y']"/></xsl:attribute><xsl:attribute name="height">100</xsl:attribute></xsl:element><xsl:text></xsl:text>
</xsl:when>
<xsl:when test="marc:subfield[@code='y' or @code='3' or @code='z']">
<xsl:call-template name="subfieldSelect">
<xsl:with-param name="codes">y3z</xsl:with-param>
</xsl:call-template>
</xsl:when>
<xsl:when test="not(marc:subfield[@code='y']) and not(marc:subfield[@code='3']) and not(marc:subfield[@code='z'])">
Click here to access online
</xsl:when>
</xsl:choose>
</a>
<xsl:choose>
<xsl:when test="position()=last()"></xsl:when>
<xsl:otherwise> | </xsl:otherwise>
</xsl:choose>
</xsl:when>
</xsl:choose>
</xsl:for-each>
</xsl:when>
<xsl:when test="count(key('item-by-status', 'available'))=0 and count(key('item-by-status', 'reference'))=0">
No copies available
</xsl:when>
<xsl:when test="count(key('item-by-status', 'available'))>0">
<span class="available">
<b><xsl:text>Copies available for loan: </xsl:text></b>
<xsl:variable name="available_items" select="key('item-by-status', 'available')"/>
<xsl:for-each select="$available_items[generate-id() = generate-id(key('item-by-status-and-branch', concat(items:status, ' ', items:homebranch))[1])]">
<xsl:value-of select="items:homebranch"/>
<xsl:if test="items:itemcallnumber != '' and items:itemcallnumber">[<xsl:value-of select="items:itemcallnumber"/>]
</xsl:if>
<xsl:text> (</xsl:text>
<xsl:value-of select="count(key('item-by-status-and-branch', concat(items:status, ' ', items:homebranch)))"/>
<xsl:text>)</xsl:text>
<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:when>
</xsl:choose>
<xsl:choose>
<xsl:when test="count(key('item-by-status', 'reference'))>0">
<span class="available">
<b><xsl:text>Copies available for reference: </xsl:text></b>
<xsl:variable name="reference_items"
select="key('item-by-status', 'reference')"/>
<xsl:for-each select="$reference_items[generate-id() = generate-id(key('item-by-status-and-branch', concat(items:status, ' ', items:homebranch))[1])]">
<xsl:value-of select="items:homebranch"/>
<xsl:if test="items:itemcallnumber != '' and items:itemcallnumber">[<xsl:value-of select="items:itemcallnumber"/>]</xsl:if>
<xsl:text> (</xsl:text>
<xsl:value-of select="count(key('item-by-status-and-branch', concat(items:status, ' ', items:homebranch)))"/>
<xsl:text>)</xsl:text>
<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:when>
</xsl:choose>
<xsl:if test="count(key('item-by-status', 'Checked out'))>0">
<span class="unavailable">
<xsl:text>Checked out (</xsl:text>
<xsl:value-of select="count(key('item-by-status', 'Checked out'))"/>
<xsl:text>). </xsl:text>
</span>
</xsl:if>
<xsl:if test="count(key('item-by-status', 'Withdrawn'))>0">
<span class="unavailable">
<xsl:text>Withdrawn (</xsl:text>
<xsl:value-of select="count(key('item-by-status', 'Withdrawn'))"/>
<xsl:text>). </xsl:text>
</span>
</xsl:if>
<xsl:if test="$hidelostitems='0' and count(key('item-by-status', 'Lost'))>0">
<span class="unavailable">
<xsl:text>Lost (</xsl:text>
<xsl:value-of select="count(key('item-by-status', 'Lost'))"/>
<xsl:text>). </xsl:text>
</span>
</xsl:if>
<xsl:if test="count(key('item-by-status', 'Damaged'))>0">
<span class="unavailable">
<xsl:text>Damaged (</xsl:text>
<xsl:value-of select="count(key('item-by-status', 'Damaged'))"/>
<xsl:text>). </xsl:text>
</span>
</xsl:if>
<xsl:if test="count(key('item-by-status', 'On Orangemanr'))>0">
<span class="unavailable">
<xsl:text>On order (</xsl:text>
<xsl:value-of select="count(key('item-by-status', 'On order'))"/>
<xsl:text>). </xsl:text>
</span>
</xsl:if>
<xsl:if test="count(key('item-by-status', 'In transit'))>0">
<span class="unavailable">
<xsl:text>In transit (</xsl:text>
<xsl:value-of select="count(key('item-by-status', 'In transit'))"/>
<xsl:text>). </xsl:text>
</span>
</xsl:if>
<xsl:if test="count(key('item-by-status', 'Waiting'))>0">
<span class="unavailable">
<xsl:text>On hold (</xsl:text>
<xsl:value-of select="count(key('item-by-status', 'Waiting'))"/>
<xsl:text>). </xsl:text>
</span>
</xsl:if>
</span>
</xsl:template>
</xsl:stylesheet>