3 <!DOCTYPE stylesheet [<!ENTITY nbsp " " >]>
5 <xsl:stylesheet version="1.0"
6 xmlns:marc="http://www.loc.gov/MARC21/slim"
7 xmlns:items="http://www.koha-community.org/items"
8 xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
9 xmlns:str="http://exslt.org/strings"
10 exclude-result-prefixes="marc items str">
12 <xsl:template name="datafield">
13 <xsl:param name="tag"/>
14 <xsl:param name="ind1"><xsl:text> </xsl:text></xsl:param>
15 <xsl:param name="ind2"><xsl:text> </xsl:text></xsl:param>
16 <xsl:param name="subfields"/>
17 <xsl:element name="datafield">
18 <xsl:attribute name="tag">
19 <xsl:value-of select="$tag"/>
21 <xsl:attribute name="ind1">
22 <xsl:value-of select="$ind1"/>
24 <xsl:attribute name="ind2">
25 <xsl:value-of select="$ind2"/>
27 <xsl:copy-of select="$subfields"/>
31 <xsl:template name="subfieldSelect">
32 <xsl:param name="codes"/>
33 <xsl:param name="delimeter"><xsl:text> </xsl:text></xsl:param>
34 <xsl:param name="subdivCodes"/>
35 <xsl:param name="subdivDelimiter"/>
36 <xsl:param name="urlencode"/>
37 <xsl:variable name="str">
38 <xsl:for-each select="marc:subfield">
39 <xsl:if test="contains($codes, @code)">
40 <xsl:if test="contains($subdivCodes, @code)">
41 <xsl:value-of select="$subdivDelimiter"/>
43 <xsl:value-of select="text()"/><xsl:value-of select="$delimeter"/>
48 <xsl:when test="$urlencode=1">
49 <xsl:value-of select="str:encode-uri(substring($str,1,string-length($str)-string-length($delimeter)), true())"/>
52 <xsl:value-of select="substring($str,1,string-length($str)-string-length($delimeter))"/>
57 <xsl:template name="buildSpaces">
58 <xsl:param name="spaces"/>
59 <xsl:param name="char"><xsl:text> </xsl:text></xsl:param>
60 <xsl:if test="$spaces>0">
61 <xsl:value-of select="$char"/>
62 <xsl:call-template name="buildSpaces">
63 <xsl:with-param name="spaces" select="$spaces - 1"/>
64 <xsl:with-param name="char" select="$char"/>
69 <xsl:template name="buildBiblioDefaultViewURL">
70 <xsl:param name="BiblioDefaultView"/>
72 <xsl:when test="$BiblioDefaultView='normal'">
73 <xsl:text>/cgi-bin/koha/opac-detail.pl?biblionumber=</xsl:text>
75 <xsl:when test="$BiblioDefaultView='isbd'">
76 <xsl:text>/cgi-bin/koha/opac-ISBDdetail.pl?biblionumber=</xsl:text>
78 <xsl:when test="$BiblioDefaultView='marc'">
79 <xsl:text>/cgi-bin/koha/opac-MARCdetail.pl?biblionumber=</xsl:text>
82 <xsl:text>/cgi-bin/koha/opac-detail.pl?biblionumber=</xsl:text>
88 <xsl:template name="chopPunctuation">
89 <xsl:param name="chopString"/>
90 <xsl:variable name="length" select="string-length($chopString)"/>
92 <xsl:when test="$length=0"/>
93 <xsl:when test="contains('.:,;/ ', substring($chopString,$length,1))">
94 <xsl:call-template name="chopPunctuation">
95 <xsl:with-param name="chopString" select="substring($chopString,1,$length - 1)"/>
98 <xsl:when test="not($chopString)"/>
99 <xsl:otherwise><xsl:value-of select="$chopString"/></xsl:otherwise>
101 <xsl:text> </xsl:text>
104 <xsl:template name="addClassRtl">
105 <xsl:variable name="lang" select="marc:subfield[@code='7']" />
106 <xsl:if test="$lang = 'ha' or $lang = 'Hebrew' or $lang = 'fa' or $lang = 'Arabe'">
107 <xsl:attribute name="class">rtl</xsl:attribute>
111 <xsl:template name="tag_title">
112 <xsl:param name="tag" />
113 <xsl:param name="label" />
114 <xsl:param name="spanclass" />
115 <xsl:if test="marc:datafield[@tag=$tag]">
116 <span class="results_summary {$spanclass}">
118 <xsl:value-of select="$label"/>: </span>
119 <xsl:for-each select="marc:datafield[@tag=$tag]">
120 <xsl:call-template name="addClassRtl" />
121 <xsl:for-each select="marc:subfield">
123 <xsl:when test="@code='a'">
124 <xsl:variable name="title" select="."/>
125 <xsl:variable name="ntitle"
126 select="translate($title, 'ˆ‰˜œ','')"/>
127 <xsl:value-of select="$ntitle" />
129 <xsl:when test="@code='b'">
130 <xsl:text>[</xsl:text>
131 <xsl:value-of select="."/>
132 <xsl:text>]</xsl:text>
134 <xsl:when test="@code='d'">
135 <xsl:text> = </xsl:text>
136 <xsl:value-of select="."/>
138 <xsl:when test="@code='e'">
139 <xsl:text> : </xsl:text>
140 <xsl:value-of select="."/>
142 <xsl:when test="@code='f'">
143 <xsl:text> / </xsl:text>
144 <xsl:value-of select="."/>
146 <xsl:when test="@code='g'">
147 <xsl:text> ; </xsl:text>
148 <xsl:value-of select="."/>
151 <xsl:if test="position()>1">
152 <xsl:text>, </xsl:text>
154 <xsl:value-of select="."/>
158 <xsl:if test="not (position() = last())">
159 <xsl:text> • </xsl:text>
166 <xsl:template name="tag_comma">
167 <xsl:param name="tag" />
168 <xsl:param name="label" />
169 <xsl:param name="spanclass" />
170 <xsl:if test="marc:datafield[@tag=$tag]">
171 <span class="results_summary {$spanclass}">
173 <xsl:value-of select="$label"/>: </span>
174 <xsl:for-each select="marc:datafield[@tag=$tag]">
175 <xsl:call-template name="addClassRtl" />
176 <xsl:for-each select="marc:subfield">
177 <xsl:if test="position()>1">
178 <xsl:text>, </xsl:text>
180 <xsl:value-of select="."/>
182 <xsl:if test="not (position() = last())">
183 <xsl:text> • </xsl:text>
190 <xsl:template name="tag_210">
191 <span class="results_summary publication">
192 <span class="label">Publication: </span>
193 <xsl:for-each select="marc:datafield[@tag=210]">
195 <xsl:call-template name="addClassRtl" />
196 <xsl:for-each select="marc:subfield">
198 <xsl:when test="@code='c' or @code='g'">
199 <xsl:if test="position()>1">
200 <xsl:text> : </xsl:text>
202 <xsl:value-of select="."/>
205 <xsl:if test="position()>1">
206 <xsl:text>, </xsl:text>
208 <xsl:value-of select="."/>
212 <xsl:if test="not (position() = last())">
213 <xsl:text> • </xsl:text>
220 <xsl:template name="tag_215">
221 <xsl:for-each select="marc:datafield[@tag=215]">
222 <span class="results_summary description">
223 <span class="label">Description: </span>
224 <xsl:if test="marc:subfield[@code='a']">
225 <xsl:value-of select="marc:subfield[@code='a']"/>
227 <xsl:if test="marc:subfield[@code='c']"> :
228 <xsl:value-of select="marc:subfield[@code='c']"/>
230 <xsl:if test="marc:subfield[@code='d']"> ;
231 <xsl:value-of select="marc:subfield[@code='d']"/>
233 <xsl:if test="marc:subfield[@code='e']"> +
234 <xsl:value-of select="marc:subfield[@code='e']"/>
240 <xsl:template name="tag_onesubject">
242 <xsl:when test="marc:subfield[@code=9]">
243 <xsl:for-each select="marc:subfield">
244 <xsl:if test="@code='9'">
245 <xsl:variable name="start" select="position()"/>
246 <xsl:variable name="ends">
247 <xsl:for-each select="../marc:subfield[position() > $start]">
248 <xsl:if test="@code=9">
249 <xsl:variable name="end" select="position() + $start"/>
250 <xsl:value-of select="$end"/>
251 <xsl:text>,</xsl:text>
255 <xsl:variable name="end">
257 <xsl:when test="string-length($ends) > 0">
258 <xsl:value-of select="substring-before($ends,',')"/>
261 <xsl:text>1000</xsl:text>
265 <xsl:variable name="display">
266 <xsl:for-each select="../marc:subfield[position() > $start and position() < $end and @code!=2 and @code!=3]">
267 <xsl:value-of select="."/>
268 <xsl:if test="not(position()=last())">
269 <xsl:text>, </xsl:text>
274 <xsl:attribute name="href">
275 <xsl:text>/cgi-bin/koha/opac-search.pl?q=an:</xsl:text>
276 <xsl:value-of select="str:encode-uri(., true())"/>
279 <xsl:when test="string-length($display) > 0">
280 <xsl:call-template name="chopPunctuation">
281 <xsl:with-param name="chopString">
282 <xsl:value-of select="$display"/>
287 <xsl:value-of select="."/>
291 <xsl:variable name="ncommas"
292 select="string-length($ends) - string-length(translate($ends, ',', ''))" />
293 <xsl:if test="$ncommas > 1">
294 <xsl:text> -- </xsl:text>
299 <xsl:when test="marc:subfield[@code='a']">
301 <xsl:attribute name="href">
302 <xsl:text>/cgi-bin/koha/opac-search.pl?q=su:</xsl:text>
303 <xsl:value-of select="str:encode-uri(marc:subfield[@code='a'], true())"/>
305 <xsl:call-template name="chopPunctuation">
306 <xsl:with-param name="chopString">
307 <xsl:call-template name="subfieldSelect">
308 <xsl:with-param name="codes">abcdfijkmnptvxyz</xsl:with-param>
309 <xsl:with-param name="subdivCodes">ijknpxyz</xsl:with-param>
310 <xsl:with-param name="subdivDelimiter">-- </xsl:with-param>
318 <xsl:if test="not(position()=last())">
319 <xsl:text> | </xsl:text>
323 <xsl:template name="tag_subject">
324 <xsl:param name="tag" />
325 <xsl:param name="label" />
326 <xsl:param name="spanclass" />
327 <xsl:if test="marc:datafield[@tag=$tag]">
328 <span class="results_summary subjects {$spanclass}">
330 <xsl:value-of select="$label"/>
331 <xsl:text>: </xsl:text>
334 <xsl:for-each select="marc:datafield[@tag=$tag]">
335 <xsl:call-template name="tag_onesubject">
343 <xsl:template name="tag_7xx">
344 <xsl:param name="tag" />
345 <xsl:param name="label" />
346 <xsl:param name="spanclass" />
347 <xsl:variable name="IdRef" select="marc:sysprefs/marc:syspref[@name='IdRef']"/>
348 <xsl:if test="marc:datafield[@tag=$tag]">
349 <span class="results_summary author {$spanclass}">
351 <xsl:value-of select="$label" />
352 <xsl:text>: </xsl:text>
355 <xsl:for-each select="marc:datafield[@tag=$tag]">
358 <xsl:when test="marc:subfield[@code=9]">
359 <xsl:attribute name="href">
360 <xsl:text>/cgi-bin/koha/opac-search.pl?q=an:</xsl:text>
361 <xsl:value-of select="str:encode-uri(marc:subfield[@code=9], true())"/>
365 <xsl:attribute name="href">
366 <xsl:text>/cgi-bin/koha/opac-search.pl?q=au:</xsl:text>
367 <xsl:value-of select="str:encode-uri(marc:subfield[@code='a'], true())"/>
368 <xsl:text>%20</xsl:text>
369 <xsl:value-of select="str:encode-uri(marc:subfield[@code='b'], true())"/>
373 <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']">
375 <xsl:when test="@code='9'">
378 <xsl:value-of select="."/>
381 <xsl:if test="not(position() = last())">
382 <xsl:text>, </xsl:text>
386 <xsl:if test="$IdRef = '1'">
387 <xsl:if test="marc:subfield[@code=3]">
388 <xsl:text> </xsl:text>
390 <xsl:attribute name="href">
391 <xsl:text>/cgi-bin/koha/opac-idref.pl?unimarc3=</xsl:text>
392 <xsl:value-of select="str:encode-uri(marc:subfield[@code=3], true())"/>
394 <xsl:attribute name="title">IdRef</xsl:attribute>
395 <xsl:attribute name="rel">gb_page_center[600,500]</xsl:attribute>
396 <xsl:text>Idref</xsl:text>
400 <xsl:if test="not(position() = last())">
401 <span style="padding: 3px;">
402 <xsl:text>;</xsl:text>