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"/>
119 <xsl:text>: </xsl:text>
121 <xsl:for-each select="marc:datafield[@tag=$tag]">
122 <xsl:call-template name="addClassRtl" />
123 <xsl:for-each select="marc:subfield">
125 <xsl:when test="@code='a'">
126 <xsl:variable name="title" select="."/>
127 <xsl:variable name="ntitle"
128 select="translate($title, 'ˆ‰˜œ','')"/>
129 <xsl:value-of select="$ntitle" />
131 <xsl:when test="@code='b'">
132 <xsl:text>[</xsl:text>
133 <xsl:value-of select="."/>
134 <xsl:text>]</xsl:text>
136 <xsl:when test="@code='d'">
137 <xsl:text> = </xsl:text>
138 <xsl:value-of select="."/>
140 <xsl:when test="@code='e'">
141 <xsl:text> : </xsl:text>
142 <xsl:value-of select="."/>
144 <xsl:when test="@code='f'">
145 <xsl:text> / </xsl:text>
146 <xsl:value-of select="."/>
148 <xsl:when test="@code='g'">
149 <xsl:text> ; </xsl:text>
150 <xsl:value-of select="."/>
153 <xsl:if test="position()>1">
154 <xsl:text>, </xsl:text>
156 <xsl:value-of select="."/>
160 <xsl:if test="not (position() = last())">
161 <xsl:text> • </xsl:text>
168 <xsl:template name="tag_comma">
169 <xsl:param name="tag" />
170 <xsl:param name="label" />
171 <xsl:param name="spanclass" />
172 <xsl:if test="marc:datafield[@tag=$tag]">
173 <span class="results_summary {$spanclass}">
175 <xsl:value-of select="$label"/>: </span>
176 <xsl:for-each select="marc:datafield[@tag=$tag]">
177 <xsl:call-template name="addClassRtl" />
178 <xsl:for-each select="marc:subfield">
179 <xsl:if test="position()>1">
180 <xsl:text>, </xsl:text>
182 <xsl:value-of select="."/>
184 <xsl:if test="not (position() = last())">
185 <xsl:text> • </xsl:text>
192 <xsl:template name="tag_210">
193 <span class="results_summary publication">
194 <span class="label">Publication: </span>
195 <xsl:for-each select="marc:datafield[@tag=210]">
197 <xsl:call-template name="addClassRtl" />
198 <xsl:for-each select="marc:subfield">
200 <xsl:when test="@code='c' or @code='g'">
201 <xsl:if test="position()>1">
202 <xsl:text> : </xsl:text>
204 <xsl:value-of select="."/>
207 <xsl:if test="position()>1">
208 <xsl:text>, </xsl:text>
210 <xsl:value-of select="."/>
214 <xsl:if test="not (position() = last())">
215 <xsl:text> • </xsl:text>
222 <xsl:template name="tag_215">
223 <xsl:for-each select="marc:datafield[@tag=215]">
224 <span class="results_summary description">
225 <span class="label">Description: </span>
226 <xsl:if test="marc:subfield[@code='a']">
227 <xsl:value-of select="marc:subfield[@code='a']"/>
229 <xsl:if test="marc:subfield[@code='c']"> :
230 <xsl:value-of select="marc:subfield[@code='c']"/>
232 <xsl:if test="marc:subfield[@code='d']"> ;
233 <xsl:value-of select="marc:subfield[@code='d']"/>
235 <xsl:if test="marc:subfield[@code='e']"> +
236 <xsl:value-of select="marc:subfield[@code='e']"/>
242 <xsl:template name="tag_onesubject">
244 <xsl:when test="marc:subfield[@code=9]">
245 <xsl:for-each select="marc:subfield">
246 <xsl:if test="@code='9'">
247 <xsl:variable name="start" select="position()"/>
248 <xsl:variable name="ends">
249 <xsl:for-each select="../marc:subfield[position() > $start]">
250 <xsl:if test="@code=9">
251 <xsl:variable name="end" select="position() + $start"/>
252 <xsl:value-of select="$end"/>
253 <xsl:text>,</xsl:text>
257 <xsl:variable name="end">
259 <xsl:when test="string-length($ends) > 0">
260 <xsl:value-of select="substring-before($ends,',')"/>
263 <xsl:text>1000</xsl:text>
267 <xsl:variable name="display">
268 <xsl:for-each select="../marc:subfield[position() > $start and position() < $end and @code!=2 and @code!=3]">
269 <xsl:value-of select="."/>
270 <xsl:if test="not(position()=last())">
271 <xsl:text>, </xsl:text>
276 <xsl:attribute name="href">
277 <xsl:text>/cgi-bin/koha/opac-search.pl?q=an:</xsl:text>
278 <xsl:value-of select="str:encode-uri(., true())"/>
281 <xsl:when test="string-length($display) > 0">
282 <xsl:call-template name="chopPunctuation">
283 <xsl:with-param name="chopString">
284 <xsl:value-of select="$display"/>
289 <xsl:value-of select="."/>
293 <xsl:variable name="ncommas"
294 select="string-length($ends) - string-length(translate($ends, ',', ''))" />
295 <xsl:if test="$ncommas > 1">
296 <xsl:text> -- </xsl:text>
301 <xsl:when test="marc:subfield[@code='a']">
303 <xsl:attribute name="href">
304 <xsl:text>/cgi-bin/koha/opac-search.pl?q=su:</xsl:text>
305 <xsl:value-of select="str:encode-uri(marc:subfield[@code='a'], true())"/>
307 <xsl:call-template name="chopPunctuation">
308 <xsl:with-param name="chopString">
309 <xsl:call-template name="subfieldSelect">
310 <xsl:with-param name="codes">abcdfijkmnptvxyz</xsl:with-param>
311 <xsl:with-param name="subdivCodes">ijknpxyz</xsl:with-param>
312 <xsl:with-param name="subdivDelimiter">-- </xsl:with-param>
320 <xsl:if test="not(position()=last())">
321 <xsl:text> | </xsl:text>
325 <xsl:template name="tag_subject">
326 <xsl:param name="tag" />
327 <xsl:param name="label" />
328 <xsl:param name="spanclass" />
329 <xsl:if test="marc:datafield[@tag=$tag]">
330 <span class="results_summary subjects {$spanclass}">
332 <xsl:value-of select="$label"/>
333 <xsl:text>: </xsl:text>
336 <xsl:for-each select="marc:datafield[@tag=$tag]">
337 <xsl:call-template name="tag_onesubject">
345 <xsl:template name="tag_7xx">
346 <xsl:param name="tag" />
347 <xsl:param name="label" />
348 <xsl:param name="spanclass" />
349 <xsl:variable name="IdRef" select="marc:sysprefs/marc:syspref[@name='IdRef']"/>
350 <xsl:if test="marc:datafield[@tag=$tag]">
351 <span class="results_summary author {$spanclass}">
353 <xsl:value-of select="$label" />
354 <xsl:text>: </xsl:text>
357 <xsl:for-each select="marc:datafield[@tag=$tag]">
360 <xsl:when test="marc:subfield[@code=9]">
361 <xsl:attribute name="href">
362 <xsl:text>/cgi-bin/koha/opac-search.pl?q=an:</xsl:text>
363 <xsl:value-of select="str:encode-uri(marc:subfield[@code=9], true())"/>
367 <xsl:attribute name="href">
368 <xsl:text>/cgi-bin/koha/opac-search.pl?q=au:</xsl:text>
369 <xsl:value-of select="str:encode-uri(marc:subfield[@code='a'], true())"/>
370 <xsl:text>%20</xsl:text>
371 <xsl:value-of select="str:encode-uri(marc:subfield[@code='b'], true())"/>
375 <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']">
377 <xsl:when test="@code='9'">
380 <xsl:value-of select="."/>
383 <xsl:if test="not(position() = last())">
384 <xsl:text>, </xsl:text>
388 <xsl:if test="$IdRef = '1'">
389 <xsl:if test="marc:subfield[@code=3]">
390 <xsl:text> </xsl:text>
392 <xsl:attribute name="href">
393 <xsl:text>/cgi-bin/koha/opac-idref.pl?unimarc3=</xsl:text>
394 <xsl:value-of select="str:encode-uri(marc:subfield[@code=3], true())"/>
396 <xsl:attribute name="title">IdRef</xsl:attribute>
397 <xsl:attribute name="rel">gb_page_center[600,500]</xsl:attribute>
398 <xsl:text>Idref</xsl:text>
402 <xsl:if test="not(position() = last())">
403 <span style="padding: 3px;">
404 <xsl:text>;</xsl:text>