[Koha-patches] [PATCH] XSL UNIMARC Improvments
Frédéric Demians
f.demians at tamil.fr
Fri Jul 8 13:32:35 CEST 2011
- Exclude 'marc' & 'item' prefix from UNIMARC util XSL to slim down
result
- Add missing NSB/NSE characters striping
- 200 fields on result/detail page: show all subfields in order, link to
detail page only on $a
- 4xx display, more fields and more subfields, respects subfields order
which matter
- Improve RAMEAU authorities linkings to subdivisions (pure XSLT)
- Add missing fields: 205, 500
- Add missing MARC21 syspref:
- DisplayOPACiconsXSLT, not implemtable in UNIMARC
- OPACURLOpenInNewWindow
- URLLinkText
- ShowISBD
Sidenote: this should have been done by people having introduced those
syspref into MARC21 XSL.
Suite
---
.../prog/en/xslt/UNIMARCslim2OPACDetail.xsl | 133 ++++--
.../prog/en/xslt/UNIMARCslim2OPACResults.xsl | 90 +++--
.../opac-tmpl/prog/en/xslt/UNIMARCslimUtils.xsl | 475 +++++++++++---------
3 files changed, 415 insertions(+), 283 deletions(-)
diff --git a/koha-tmpl/opac-tmpl/prog/en/xslt/UNIMARCslim2OPACDetail.xsl b/koha-tmpl/opac-tmpl/prog/en/xslt/UNIMARCslim2OPACDetail.xsl
index 2832b6b..5f6daa2 100644
--- a/koha-tmpl/opac-tmpl/prog/en/xslt/UNIMARCslim2OPACDetail.xsl
+++ b/koha-tmpl/opac-tmpl/prog/en/xslt/UNIMARCslim2OPACDetail.xsl
@@ -15,45 +15,89 @@
</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="DisplayOPACiconsXSLT" select="marc:sysprefs/marc:syspref[@name='DisplayOPACiconsXSLT']" />
+ <xsl:variable name="OPACURLOpenInNewWindow" select="marc:sysprefs/marc:syspref[@name='OPACURLOpenInNewWindo w']"/>
+ <xsl:variable name="URLLinkText" select="marc:sysprefs/marc:syspref[@name='URLLinkText']"/>
+ <xsl:variable name="ShowISBD" select="marc:sysprefs/marc:syspref[@name='viewISBD']"/>
<xsl:if test="marc:datafield[@tag=200]">
<xsl:for-each select="marc:datafield[@tag=200]">
<h1>
<xsl:call-template name="addClassRtl" />
- <xsl:variable name="title" select="marc:subfield[@code='a']"/>
- <xsl:variable name="ntitle"
- select="translate($title, '˜œ','')"/>
- <xsl:value-of select="$ntitle" />
- <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>
+ <xsl:for-each select="marc:subfield">
+ <xsl:choose>
+ <xsl:when test="@code='a'">
+ <xsl:variable name="title" select="."/>
+ <xsl:variable name="ntitle"
+ select="translate($title, 'ˆ‰˜œ','')"/>
+ <xsl:value-of select="$ntitle" />
+ </xsl:when>
+ <xsl:when test="@code='b'">
+ <xsl:text> [</xsl:text>
+ <xsl:value-of select="."/>
+ <xsl:text>]</xsl:text>
+ </xsl:when>
+ <xsl:when test="@code='d'">
+ <xsl:text> = </xsl:text>
+ <xsl:value-of select="."/>
+ </xsl:when>
+ <xsl:when test="@code='e'">
+ <xsl:text> : </xsl:text>
+ <xsl:value-of select="."/>
+ </xsl:when>
+ <xsl:when test="@code='f'">
+ <xsl:text> / </xsl:text>
+ <xsl:value-of select="."/>
+ </xsl:when>
+ <xsl:when test="@code='g'">
+ <xsl:text> ; </xsl:text>
+ <xsl:value-of select="."/>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:text>, </xsl:text>
+ <xsl:value-of select="."/>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:for-each>
</h1>
</xsl:for-each>
</xsl:if>
- <xsl:call-template name="tag_4xx" />
+ <div id="views">
+ <span class="view">
+ <span id="Normalview">Normal View</span>
+ </span>
+ <span class="view">
+ <a id="MARCviewPop" href="/cgi-bin/koha/opac-showmarc.pl?id={marc:datafield[@tag=090]/marc:subfield[@code='a']}" title="MARC" rel="gb_page_center[600,500]">MARC View</a>
+ </span>
+ <span class="view">
+ <a id="MARCview" href="/cgi-bin/koha/opac-MARCdetail.pl?biblionumber={marc:datafield[@tag=090]/marc:subfield[@code='a']}" title="MARC">Expanded MARC View</a>
+ </span>
+ <xsl:if test="$ShowISBD!='0'">
+ <span class="view">
+ <a id="ISBDview" href="/cgi-bin/koha/opac-ISBDdetail.pl?biblionumber={marc:datafield[@tag=090]/marc:subfield[@code='a']}">Card View (ISBD)</a>
+ </span>
+ </xsl:if>
+ </div>
+
+ <xsl:call-template name="tag_title">
+ <xsl:with-param name="tag">454</xsl:with-param>
+ <xsl:with-param name="label">Translation of</xsl:with-param>
+ </xsl:call-template>
+
+ <xsl:call-template name="tag_title">
+ <xsl:with-param name="tag">461</xsl:with-param>
+ <xsl:with-param name="label">Set Level</xsl:with-param>
+ </xsl:call-template>
+
+ <xsl:call-template name="tag_title">
+ <xsl:with-param name="tag">464</xsl:with-param>
+ <xsl:with-param name="label">Piece-Analytic Level</xsl:with-param>
+ </xsl:call-template>
<xsl:call-template name="tag_7xx">
<xsl:with-param name="tag">700</xsl:with-param>
@@ -85,9 +129,19 @@
<xsl:with-param name="label">Corporate Author (Secondary)</xsl:with-param>
</xsl:call-template>
+ <xsl:call-template name="tag_title">
+ <xsl:with-param name="tag">500</xsl:with-param>
+ <xsl:with-param name="label">Uniform Title</xsl:with-param>
+ </xsl:call-template>
+
+ <xsl:call-template name="tag_title">
+ <xsl:with-param name="tag">503</xsl:with-param>
+ <xsl:with-param name="label">Uniform Conventional Heading</xsl:with-param>
+ </xsl:call-template>
+
<xsl:if test="marc:datafield[@tag=101]">
- <span class="results_summary">
- <span class="label">Language: </span>
+ <span class="results_summary">
+ <span class="label">Language:</span>
<xsl:for-each select="marc:datafield[@tag=101]">
<xsl:for-each select="marc:subfield">
<xsl:choose>
@@ -133,6 +187,11 @@
</span>
</xsl:if>
+ <xsl:call-template name="tag_comma">
+ <xsl:with-param name="tag">205</xsl:with-param>
+ <xsl:with-param name="label">Edition Statement</xsl:with-param>
+ </xsl:call-template>
+
<xsl:call-template name="tag_210" />
<xsl:call-template name="tag_215" />
@@ -350,24 +409,30 @@
<xsl:if test="marc:datafield[@tag=856]">
<span class="results_summary">
- <span class="label">Online Resources: </span>
+ <span class="label">Online Resources:</span>
<xsl:for-each select="marc:datafield[@tag=856]">
- <xsl:variable name="SubqText"><xsl:value-of select="marc:subfield[@code='q']"/></xsl:variable>
<a>
<xsl:attribute name="href">
<xsl:value-of select="marc:subfield[@code='u']"/>
</xsl:attribute>
+ <xsl:if test="$OPACURLOpenInNewWindow='1'">
+ <xsl:attribute name="target">_blank</xsl:attribute>
+ </xsl:if>
<xsl:choose>
- <xsl:when test="($Show856uAsImage='Details' 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:choose>
+ <xsl:when test="$URLLinkText!=''">
+ <xsl:value-of select="$URLLinkText"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:text>Click here to access online</xsl:text>
+ </xsl:otherwise>
+ </xsl:choose>
</xsl:when>
</xsl:choose>
</a>
diff --git a/koha-tmpl/opac-tmpl/prog/en/xslt/UNIMARCslim2OPACResults.xsl b/koha-tmpl/opac-tmpl/prog/en/xslt/UNIMARCslim2OPACResults.xsl
index 831724c..5364ded 100644
--- a/koha-tmpl/opac-tmpl/prog/en/xslt/UNIMARCslim2OPACResults.xsl
+++ b/koha-tmpl/opac-tmpl/prog/en/xslt/UNIMARCslim2OPACResults.xsl
@@ -18,7 +18,6 @@
</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)"/>
@@ -31,42 +30,65 @@
<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, '˜œ','')"/>
- <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:for-each select="marc:subfield">
+ <xsl:choose>
+ <xsl:when test="@code='a'">
+ <xsl:variable name="title" select="."/>
+ <xsl:variable name="ntitle"
+ select="translate($title, 'ˆ‰˜œ','')"/>
+ <a>
+ <xsl:attribute name="href">
+ <xsl:text>/cgi-bin/koha/opac-detail.pl?biblionumber=</xsl:text>
+ <xsl:value-of select="$biblionumber"/>
+ </xsl:attribute>
+ <xsl:value-of select="$ntitle" />
+ </a>
+ </xsl:when>
+ <xsl:when test="@code='b'">
+ <xsl:text> [</xsl:text>
<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:text>]</xsl:text>
+ </xsl:when>
+ <xsl:when test="@code='d'">
+ <xsl:text> = </xsl:text>
+ <xsl:value-of select="."/>
+ </xsl:when>
+ <xsl:when test="@code='e'">
+ <xsl:text> : </xsl:text>
+ <xsl:value-of select="."/>
+ </xsl:when>
+ <xsl:when test="@code='f'">
+ <xsl:text> / </xsl:text>
+ <xsl:value-of select="."/>
+ </xsl:when>
+ <xsl:when test="@code='g'">
+ <xsl:text> ; </xsl:text>
+ <xsl:value-of select="."/>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:text>, </xsl:text>
+ <xsl:value-of select="."/>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:for-each>
</xsl:for-each>
</xsl:if>
- <xsl:call-template name="tag_4xx" />
+ <xsl:call-template name="tag_title">
+ <xsl:with-param name="tag">454</xsl:with-param>
+ <xsl:with-param name="label">Translation of</xsl:with-param>
+ </xsl:call-template>
+
+ <xsl:call-template name="tag_title">
+ <xsl:with-param name="tag">461</xsl:with-param>
+ <xsl:with-param name="label">Set Level</xsl:with-param>
+ </xsl:call-template>
+
+ <xsl:call-template name="tag_title">
+ <xsl:with-param name="tag">464</xsl:with-param>
+ <xsl:with-param name="label">Piece-Analytic Level</xsl:with-param>
+ </xsl:call-template>
<xsl:call-template name="tag_210" />
@@ -77,7 +99,6 @@
<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>
@@ -85,9 +106,6 @@
<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>
diff --git a/koha-tmpl/opac-tmpl/prog/en/xslt/UNIMARCslimUtils.xsl b/koha-tmpl/opac-tmpl/prog/en/xslt/UNIMARCslimUtils.xsl
index 8eec0fd..146b88c 100644
--- a/koha-tmpl/opac-tmpl/prog/en/xslt/UNIMARCslimUtils.xsl
+++ b/koha-tmpl/opac-tmpl/prog/en/xslt/UNIMARCslimUtils.xsl
@@ -2,7 +2,10 @@
<!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:stylesheet version="1.0"
+ xmlns:marc="http://www.loc.gov/MARC21/slim"
+ xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+ exclude-result-prefixes="marc items">
<xsl:template name="datafield">
<xsl:param name="tag"/>
@@ -23,37 +26,158 @@
</xsl:element>
</xsl:template>
+ <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>
+ </xsl:variable>
+ <xsl:value-of select="substring($str,1,string-length($str)-string-length($delimeter))"/>
+ </xsl:template>
+
+ <xsl:template name="buildSpaces">
+ <xsl:param name="spaces"/>
+ <xsl:param name="char"><xsl:text> </xsl:text></xsl:param>
+ <xsl:if test="$spaces>0">
+ <xsl:value-of select="$char"/>
+ <xsl:call-template name="buildSpaces">
+ <xsl:with-param name="spaces" select="$spaces - 1"/>
+ <xsl:with-param name="char" select="$char"/>
+ </xsl:call-template>
+ </xsl:if>
+ </xsl:template>
+
+ <xsl:template name="chopPunctuation">
+ <xsl:param name="chopString"/>
+ <xsl:variable name="length" select="string-length($chopString)"/>
+ <xsl:choose>
+ <xsl:when test="$length=0"/>
+ <xsl:when test="contains('.:,;/ ', substring($chopString,$length,1))">
+ <xsl:call-template name="chopPunctuation">
+ <xsl:with-param name="chopString" select="substring($chopString,1,$length - 1)"/>
+ </xsl:call-template>
+ </xsl:when>
+ <xsl:when test="not($chopString)"/>
+ <xsl:otherwise><xsl:value-of select="$chopString"/></xsl:otherwise>
+ </xsl:choose>
+ <xsl:text> </xsl:text>
+ </xsl:template>
+
+ <xsl:template name="addClassRtl">
+ <xsl:variable name="lang" select="marc:subfield[@code='7']" />
+ <xsl:if test="$lang = 'ha' or $lang = 'Hebrew' or $lang = 'fa' or $lang = 'Arabe'">
+ <xsl:attribute name="class">rtl</xsl:attribute>
+ </xsl:if>
+ </xsl:template>
+
+ <xsl:template name="tag_title">
+ <xsl:param name="tag" />
+ <xsl:param name="label" />
+ <xsl:if test="marc:datafield[@tag=$tag]">
+ <span class="results_summary">
+ <span class="label">
+ <xsl:value-of select="$label"/>: </span>
+ <xsl:for-each select="marc:datafield[@tag=$tag]">
+ <xsl:call-template name="addClassRtl" />
+ <xsl:for-each select="marc:subfield">
+ <xsl:choose>
+ <xsl:when test="@code='a'">
+ <xsl:variable name="title" select="."/>
+ <xsl:variable name="ntitle"
+ select="translate($title, 'ˆ‰˜œ','')"/>
+ <xsl:value-of select="$ntitle" />
+ </xsl:when>
+ <xsl:when test="@code='b'">
+ <xsl:text>[</xsl:text>
+ <xsl:value-of select="."/>
+ <xsl:text>]</xsl:text>
+ </xsl:when>
+ <xsl:when test="@code='d'">
+ <xsl:text> = </xsl:text>
+ <xsl:value-of select="."/>
+ </xsl:when>
+ <xsl:when test="@code='e'">
+ <xsl:text> : </xsl:text>
+ <xsl:value-of select="."/>
+ </xsl:when>
+ <xsl:when test="@code='f'">
+ <xsl:text> / </xsl:text>
+ <xsl:value-of select="."/>
+ </xsl:when>
+ <xsl:when test="@code='g'">
+ <xsl:text> ; </xsl:text>
+ <xsl:value-of select="."/>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:if test="position()>1">
+ <xsl:text>, </xsl:text>
+ </xsl:if>
+ <xsl:value-of select="."/>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:for-each>
+ <xsl:if test="not (position() = last())">
+ <xsl:text> • </xsl:text>
+ </xsl:if>
+ </xsl:for-each>
+ </span>
+ </xsl:if>
+ </xsl:template>
+
+ <xsl:template name="tag_comma">
+ <xsl:param name="tag" />
+ <xsl:param name="label" />
+ <xsl:if test="marc:datafield[@tag=$tag]">
+ <span class="results_summary">
+ <span class="label">
+ <xsl:value-of select="$label"/>: </span>
+ <xsl:for-each select="marc:datafield[@tag=$tag]">
+ <xsl:call-template name="addClassRtl" />
+ <xsl:for-each select="marc:subfield">
+ <xsl:if test="position()>1">
+ <xsl:text>, </xsl:text>
+ </xsl:if>
+ <xsl:value-of select="."/>
+ </xsl:for-each>
+ <xsl:if test="not (position() = last())">
+ <xsl:text> • </xsl:text>
+ </xsl:if>
+ </xsl:for-each>
+ </span>
+ </xsl:if>
+ </xsl:template>
+
<xsl:template name="tag_210">
<span class="results_summary">
- <span class="label">Publication: </span>
+ <span class="label">Publication:</span>
<xsl:for-each select="marc:datafield[@tag=210]">
<span>
<xsl:call-template name="addClassRtl" />
- <xsl:value-of select="marc:subfield[@code='a']"/>
- <xsl:if test="marc:subfield[@code='b']">
- <xsl:if test="marc:subfield[@code='a']">, </xsl:if>
- <xsl:value-of select="marc:subfield[@code='b']"/>
- </xsl:if>
- <xsl:if test="marc:subfield[@code='a' or @code='b']">
- <xsl:if test="marc:subfield[@code='a']"> : </xsl:if>
- <xsl:value-of select="marc:subfield[@code='c']"/>
- </xsl:if>
- <xsl:if test="marc:subfield[@code='d']">
- <xsl:if test="marc:subfield[@code='a' or @code='c']">, </xsl:if>
- <xsl:value-of select="marc:subfield[@code='d']"/>
- </xsl:if>
- <xsl:if test="marc:subfield[@code='e']">
- <xsl:if test="marc:subfield[@code='a' or @code='c' or @code='d']"> — </xsl:if>
- <xsl:value-of select="marc:subfield[@code='e']"/>
- </xsl:if>
- <xsl:if test="marc:subfield[@code='g']">
- <xsl:if test="marc:subfield[@code='e']"> : </xsl:if>
- <xsl:value-of select="marc:subfield[@code='g']"/>
- </xsl:if>
- <xsl:if test="marc:subfield[@code='h']">
- <xsl:if test="marc:subfield[@code='e' or @code='g']">, </xsl:if>
- <xsl:value-of select="marc:subfield[@code='h']"/>
- </xsl:if>
+ <xsl:for-each select="marc:subfield">
+ <xsl:choose>
+ <xsl:when test="@code='c' or @code='g'">
+ <xsl:if test="position()>1">
+ <xsl:text> : </xsl:text>
+ </xsl:if>
+ <xsl:value-of select="."/>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:if test="position()>1">
+ <xsl:text>, </xsl:text>
+ </xsl:if>
+ <xsl:value-of select="."/>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:for-each>
<xsl:if test="not (position() = last())">
<xsl:text> • </xsl:text>
</xsl:if>
@@ -62,7 +186,7 @@
</span>
</xsl:template>
- <xsl:template name="tag_215">
+ <xsl:template name="tag_215">
<xsl:for-each select="marc:datafield[@tag=215]">
<span class="results_summary">
<span class="label">Description: </span>
@@ -82,219 +206,144 @@
</xsl:for-each>
</xsl:template>
- <xsl:template name="tag_4xx">
- <xsl:for-each select="marc:datafield[@tag=464 or @tag=461]">
- <span class="results_summary">
- <span class="label">Linked with: </span>
- <span>
- <xsl:call-template name="addClassRtl" />
- <xsl:if test="marc:subfield[@code='t']">
- <xsl:value-of select="marc:subfield[@code='t']"/>
- </xsl:if>
- <xsl:if test="marc:subfield[@code='e']"> :
- <xsl:value-of select="marc:subfield[@code='e']"/>
- </xsl:if>
- <xsl:if test="marc:subfield[@code='f']"> /
- <xsl:value-of select="marc:subfield[@code='f']"/>
- </xsl:if>
- <xsl:if test="marc:subfield[@code='v']">,
- <xsl:value-of select="marc:subfield[@code='v']"/>
- </xsl:if>
- </span>
- </span>
- </xsl:for-each>
- </xsl:template>
-
- <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>
- </xsl:variable>
- <xsl:value-of select="substring($str,1,string-length($str)-string-length($delimeter))"/>
- </xsl:template>
-
- <xsl:template name="buildSpaces">
- <xsl:param name="spaces"/>
- <xsl:param name="char"><xsl:text> </xsl:text></xsl:param>
- <xsl:if test="$spaces>0">
- <xsl:value-of select="$char"/>
- <xsl:call-template name="buildSpaces">
- <xsl:with-param name="spaces" select="$spaces - 1"/>
- <xsl:with-param name="char" select="$char"/>
- </xsl:call-template>
- </xsl:if>
- </xsl:template>
-
- <xsl:template name="chopPunctuation">
- <xsl:param name="chopString"/>
- <xsl:variable name="length" select="string-length($chopString)"/>
- <xsl:choose>
- <xsl:when test="$length=0"/>
- <xsl:when test="contains('.:,;/ ', substring($chopString,$length,1))">
- <xsl:call-template name="chopPunctuation">
- <xsl:with-param name="chopString" select="substring($chopString,1,$length - 1)"/>
- </xsl:call-template>
- </xsl:when>
- <xsl:when test="not($chopString)"/>
- <xsl:otherwise><xsl:value-of select="$chopString"/></xsl:otherwise>
- </xsl:choose>
- <xsl:text> </xsl:text>
- </xsl:template>
-
- <xsl:template name="addClassRtl">
- <xsl:variable name="lang" select="marc:subfield[@code='7']" />
- <xsl:if test="$lang = 'ha' or $lang = 'Hebrew' or $lang = 'fa' or $lang = 'Arabe'">
- <xsl:attribute name="class">rtl</xsl:attribute>
- </xsl:if>
- </xsl:template>
-
- <xsl:template name="tag_title">
- <xsl:param name="tag" />
- <xsl:param name="label" />
- <xsl:if test="marc:datafield[@tag=$tag]">
- <span class="results_summary">
- <span class="label"><xsl:value-of select="$label"/>: </span>
- <xsl:for-each select="marc:datafield[@tag=$tag]">
- <xsl:value-of select="marc:subfield[@code='a']" />
- <xsl:if test="marc:subfield[@code='d']">
- <xsl:text> : </xsl:text>
- <xsl:value-of select="marc:subfield[@code='e']"/>
- </xsl:if>
- <xsl:if test="marc:subfield[@code='e']">
- <xsl:for-each select="marc:subfield[@code='e']">
- <xsl:text> </xsl:text>
- <xsl:value-of select="."/>
- </xsl:for-each>
- </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='h']">
- <xsl:text>, </xsl:text>
- <xsl:value-of select="marc:subfield[@code='h']"/>
- </xsl:if>
- <xsl:if test="marc:subfield[@code='i']">
- <xsl:text>, </xsl:text>
- <xsl:value-of select="marc:subfield[@code='i']"/>
- </xsl:if>
- <xsl:if test="marc:subfield[@code='v']">
- <xsl:text>, </xsl:text>
- <xsl:value-of select="marc:subfield[@code='v']"/>
- </xsl:if>
- <xsl:if test="marc:subfield[@code='x']">
- <xsl:text>, </xsl:text>
- <xsl:value-of select="marc:subfield[@code='x']"/>
- </xsl:if>
- <xsl:if test="marc:subfield[@code='z']">
- <xsl:text>, </xsl:text>
- <xsl:value-of select="marc:subfield[@code='z']"/>
+ <xsl:template name="tag_onesubject">
+ <xsl:choose>
+ <xsl:when test="marc:subfield[@code=9]">
+ <xsl:for-each select="marc:subfield">
+ <xsl:if test="@code='9'">
+ <xsl:variable name="start" select="position()"/>
+ <xsl:variable name="ends">
+ <xsl:for-each select="../marc:subfield[position() > $start]">
+ <xsl:if test="@code=3 or @code=9 or @code=2">
+ <xsl:variable name="end" select="position() + $start"/>
+ <xsl:value-of select="$end"/>
+ <xsl:text>,</xsl:text>
+ </xsl:if>
+ </xsl:for-each>
+ </xsl:variable>
+ <xsl:variable name="end">
+ <xsl:choose>
+ <xsl:when test="string-length($ends) > 0">
+ <xsl:value-of select="substring-before($ends,',')"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:text>1000</xsl:text>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:variable>
+ <xsl:variable name="display">
+ <xsl:for-each select="../marc:subfield[position() > $start and position() < $end]">
+ <xsl:value-of select="."/>
+ <xsl:if test="not(position()=last())">
+ <xsl:text>, </xsl:text>
+ </xsl:if>
+ </xsl:for-each>
+ </xsl:variable>
+ <a>
+ <xsl:attribute name="href">
+ <xsl:text>/cgi-bin/koha/opac-search.pl?q=an:</xsl:text>
+ <xsl:value-of select="."/>
+ </xsl:attribute>
+ <xsl:value-of select="$display"/>
+ </a>
+ <xsl:variable name="ncommas"
+ select="string-length($ends) - string-length(translate($ends, ',', ''))" />
+ <xsl:if test="$ncommas > 1">
+ <xsl:text> -- </xsl:text>
+ </xsl:if>
</xsl:if>
</xsl:for-each>
- </span>
+ </xsl:when>
+ <xsl:otherwise>
+ <a>
+ <xsl:attribute name="href">
+ <xsl:text>/cgi-bin/koha/opac-search.pl?q=su:</xsl:text>
+ <xsl:value-of select="marc:subfield[@code='a']"/>
+ </xsl:attribute>
+ <xsl:call-template name="chopPunctuation">
+ <xsl:with-param name="chopString">
+ <xsl:call-template name="subfieldSelect">
+ <xsl:with-param name="codes">abcdfijkmnpvxyz</xsl:with-param>
+ <xsl:with-param name="subdivCodes">ijknpxyz</xsl:with-param>
+ <xsl:with-param name="subdivDelimiter">-- </xsl:with-param>
+ </xsl:call-template>
+ </xsl:with-param>
+ </xsl:call-template>
+ </a>
+ </xsl:otherwise>
+ </xsl:choose>
+ <xsl:if test="not(position()=last())">
+ <xsl:text> | </xsl:text>
</xsl:if>
</xsl:template>
-
<xsl:template name="tag_subject">
<xsl:param name="tag" />
<xsl:param name="label" />
<xsl:if test="marc:datafield[@tag=$tag]">
<span class="results_summary">
- <span class="label"><xsl:value-of select="$label"/>: </span>
- <xsl:for-each select="marc:datafield[@tag=$tag]">
- <a>
- <xsl:choose>
- <xsl:when test="marc:subfield[@code=9]">
- <xsl:attribute name="href">/cgi-bin/koha/opac-search.pl?q=an:<xsl:value-of select="marc:subfield[@code=9]"/></xsl:attribute>
- </xsl:when>
- <xsl:otherwise>
- <xsl:attribute name="href">/cgi-bin/koha/opac-search.pl?q=su:<xsl:value-of select="marc:subfield[@code='a']"/></xsl:attribute>
- </xsl:otherwise>
- </xsl:choose>
- <xsl:call-template name="chopPunctuation">
- <xsl:with-param name="chopString">
- <xsl:call-template name="subfieldSelect">
- <xsl:with-param name="codes">abcdjpvxyz</xsl:with-param>
- <xsl:with-param name="subdivCodes">jpxyz</xsl:with-param>
- <xsl:with-param name="subdivDelimiter">-- </xsl:with-param>
- </xsl:call-template>
- </xsl:with-param>
+ <span class="label">
+ <xsl:value-of select="$label"/>
+ <xsl:text>: </xsl:text>
+ </span>
+ <span class="value">
+ <xsl:for-each select="marc:datafield[@tag=$tag]">
+ <xsl:call-template name="tag_onesubject">
</xsl:call-template>
- </a>
- <xsl:if test="not (position()=last())">
- <xsl:text> | </xsl:text>
- </xsl:if>
- </xsl:for-each>
+ </xsl:for-each>
+ </span>
</span>
</xsl:if>
</xsl:template>
-
<xsl:template name="tag_7xx">
<xsl:param name="tag" />
<xsl:param name="label" />
<xsl:if test="marc:datafield[@tag=$tag]">
<span class="results_summary">
- <span class="label"><xsl:value-of select="$label" />: </span>
- <xsl:for-each select="marc:datafield[@tag=$tag]">
- <span>
- <xsl:call-template name="addClassRtl" />
+ <span class="label">
+ <xsl:value-of select="$label" />
+ <xsl:text>: </xsl:text>
+ </span>
+ <span class="value">
+ <xsl:for-each select="marc:datafield[@tag=$tag]">
<a>
<xsl:choose>
<xsl:when test="marc:subfield[@code=9]">
- <xsl:attribute name="href">/cgi-bin/koha/opac-search.pl?q=an:<xsl:value-of select="marc:subfield[@code=9]"/></xsl:attribute>
+ <xsl:attribute name="href">
+ <xsl:text>/cgi-bin/koha/opac-search.pl?q=an:</xsl:text>
+ <xsl:value-of select="marc:subfield[@code=9]"/>
+ </xsl:attribute>
</xsl:when>
<xsl:otherwise>
- <xsl:attribute name="href">/cgi-bin/koha/opac-search.pl?q=au:<xsl:value-of select="marc:subfield[@code='a']"/><xsl:text> </xsl:text><xsl:value-of select="marc:subfield[@code='b']"/></xsl:attribute>
+ <xsl:attribute name="href">
+ <xsl:text>/cgi-bin/koha/opac-search.pl?q=au:</xsl:text>
+ <xsl:value-of select="marc:subfield[@code='a']"/>
+ <xsl:text> </xsl:text>
+ <xsl:value-of select="marc:subfield[@code='b']"/>
+ </xsl:attribute>
</xsl:otherwise>
</xsl:choose>
- <xsl:if test="marc:subfield[@code='a']">
- <xsl:value-of select="marc:subfield[@code='a']"/>
- </xsl:if>
- <xsl:if test="marc:subfield[@code='b']">
- <xsl:text>, </xsl:text>
- <xsl:value-of select="marc:subfield[@code='b']"/>
- </xsl:if>
- <xsl:if test="marc:subfield[@code='c']">
- <xsl:text>, </xsl:text>
- <xsl:value-of select="marc:subfield[@code='c']"/>
- </xsl:if>
- <xsl:if test="marc:subfield[@code='d']">
- <xsl:text> </xsl:text>
- <xsl:value-of select="marc:subfield[@code='d']"/>
- </xsl:if>
- <xsl:if test="marc:subfield[@code='f']">
- <span dir="ltr">
- <xsl:text> (</xsl:text>
- <xsl:value-of select="marc:subfield[@code='f']"/>
- <xsl:text>)</xsl:text>
- </span>
- </xsl:if>
- <xsl:if test="marc:subfield[@code='g']">
- <xsl:text> </xsl:text>
- <xsl:value-of select="marc:subfield[@code='g']"/>
- </xsl:if>
- <xsl:if test="marc:subfield[@code='p']">
- <xsl:text> </xsl:text>
- <xsl:value-of select="marc:subfield[@code='p']"/>
- </xsl:if>
+ <xsl:for-each select="marc:subfield[@code='a' or @code='b' or @code='4' or @code='c' or @code='d' or @code='f' or @code='g' or @code='p']">
+ <xsl:choose>
+ <xsl:when test="@code='9'">
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select="."/>
+ </xsl:otherwise>
+ </xsl:choose>
+ <xsl:if test="not(position() = last())">
+ <xsl:text>, </xsl:text>
+ </xsl:if>
+ </xsl:for-each>
</a>
- </span>
- <xsl:if test="not (position() = last())">
- <xsl:text> ; </xsl:text>
- </xsl:if>
- </xsl:for-each>
+ <xsl:if test="not(position() = last())">
+ <span style="padding: 3px;">
+ <xsl:text>;</xsl:text>
+ </span>
+ </xsl:if>
+ </xsl:for-each>
+ </span>
</span>
</xsl:if>
</xsl:template>
--
1.7.5.1
More information about the Koha-patches
mailing list