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-214">
194 <xsl:when test="marc:datafield[@tag=210] and marc:datafield[@tag=214]">
195 <xsl:call-template name="tag_214" />
197 <xsl:when test="marc:datafield[@tag=214]">
198 <xsl:call-template name="tag_214" />
200 <xsl:when test="marc:datafield[@tag=210]">
201 <xsl:call-template name="tag_210" />
206 <xsl:template name="tag_210">
207 <span class="results_summary publication">
208 <span class="label">Publication: </span>
209 <xsl:for-each select="marc:datafield[@tag=210]">
210 <xsl:if test="not(position() = 1)">
214 <xsl:call-template name="addClassRtl" />
215 <xsl:for-each select="marc:subfield[@code='a' or @code='b' or @code='c' or @code='d' or @code='g']">
217 <xsl:when test="@code='a'">
218 <xsl:value-of select="."/>
219 <xsl:if test="position() != last()">
220 <xsl:text> : </xsl:text>
223 <xsl:when test="@code='b'">
224 <xsl:value-of select="."/>
225 <xsl:if test="position() != last()">
226 <xsl:text>, </xsl:text>
229 <xsl:when test="@code='c' or @code='g'">
231 <xsl:attribute name="href">/cgi-bin/koha/opac-search.pl?q=pb:<xsl:value-of select="str:encode-uri(., true())"/></xsl:attribute>
232 <xsl:attribute name="title">Search for publisher</xsl:attribute>
233 <xsl:value-of select="."/>
235 <xsl:if test="position() != last()">
236 <xsl:text>, </xsl:text>
239 <xsl:when test="@code='d'">
240 <xsl:value-of select="."/>
241 <xsl:if test="position() != last()">
242 <xsl:text>, </xsl:text>
252 <xsl:template name="tag_214">
253 <xsl:for-each select="marc:datafield[@tag=214]">
254 <xsl:sort select="@ind2" data-type="number" />
255 <span class="results_summary publication">
258 <xsl:when test="@ind2=1">Production: </xsl:when>
259 <xsl:when test="@ind2=2">Distribution: </xsl:when>
260 <xsl:when test="@ind2=3">Manufacture: </xsl:when>
261 <xsl:when test="@ind2=4">
263 <xsl:when test="substring(marc:subfield[@code='d'],1,1)='C'">Copyright date: </xsl:when>
264 <xsl:when test="substring(marc:subfield[@code='d'],1,1)='P'">Protection date: </xsl:when>
265 <xsl:otherwise>Copyright date / protection date: </xsl:otherwise>
268 <xsl:otherwise>Publication: </xsl:otherwise>
272 <xsl:call-template name="addClassRtl" />
273 <xsl:for-each select="marc:subfield">
275 <xsl:when test="@code='a'">
276 <xsl:value-of select="."/>
277 <xsl:if test="position() != last()">
278 <xsl:text> : </xsl:text>
281 <xsl:when test="@code='b'">
282 <xsl:value-of select="."/>
283 <xsl:if test="position() != last()">
284 <xsl:text>, </xsl:text>
287 <xsl:when test="@code='c'">
289 <xsl:attribute name="href">/cgi-bin/koha/opac-search.pl?q=pb:<xsl:value-of select="str:encode-uri(., true())"/></xsl:attribute>
290 <xsl:attribute name="title">Search for publisher</xsl:attribute>
291 <xsl:value-of select="."/>
294 <xsl:when test="@code='d'">
295 <xsl:if test="not(position()=1)">
296 <xsl:text>, </xsl:text>
299 <xsl:when test="substring(.,1,1)='C'">
300 <xsl:value-of select="substring(.,2)"/>
302 <xsl:when test="substring(.,1,1)='P'">
303 <xsl:value-of select="substring(.,2)"/>
306 <xsl:value-of select="."/>
315 <xsl:call-template name="tag_214_r" />
316 <xsl:call-template name="tag_214_s" />
319 <xsl:template name="tag_214_s">
320 <xsl:if test="marc:datafield[@tag=214]/marc:subfield[@code='s']">
321 <span class="results_summary tag_214_s">
322 <span class="label">Printing and/or Publishing Information Transcribed as Found in the Colophon: </span>
323 <xsl:for-each select="marc:datafield[@tag=214]/marc:subfield[@code='s']">
324 <xsl:value-of select="."/>
326 <xsl:when test="position()=last()">
327 <xsl:text>.</xsl:text>
330 <xsl:text>, </xsl:text>
338 <xsl:template name="tag_214_r">
339 <xsl:if test="marc:datafield[@tag=214]/marc:subfield[@code='r']">
340 <span class="results_summary tag_214_r">
341 <span class="label">Printing and/or Publishing Information Transcribed as Found in the Main Source of Information: </span>
342 <xsl:for-each select="marc:datafield[@tag=214]/marc:subfield[@code='r']">
343 <xsl:value-of select="."/>
345 <xsl:when test="position()=last()">
346 <xsl:text>.</xsl:text>
349 <xsl:text>, </xsl:text>
357 <xsl:template name="tag_215">
358 <xsl:for-each select="marc:datafield[@tag=215]">
359 <span class="results_summary description">
360 <span class="label">Description: </span>
361 <xsl:if test="marc:subfield[@code='a']">
362 <xsl:value-of select="marc:subfield[@code='a']"/>
364 <xsl:if test="marc:subfield[@code='c']"> :
365 <xsl:value-of select="marc:subfield[@code='c']"/>
367 <xsl:if test="marc:subfield[@code='d']"> ;
368 <xsl:value-of select="marc:subfield[@code='d']"/>
370 <xsl:if test="marc:subfield[@code='e']"> +
371 <xsl:value-of select="marc:subfield[@code='e']"/>
377 <xsl:template name="tag_onesubject">
379 <xsl:when test="marc:subfield[@code=9]">
380 <xsl:for-each select="marc:subfield">
381 <xsl:if test="@code='9'">
382 <xsl:variable name="start" select="position()"/>
383 <xsl:variable name="ends">
384 <xsl:for-each select="../marc:subfield[position() > $start]">
385 <xsl:if test="@code=9">
386 <xsl:variable name="end" select="position() + $start"/>
387 <xsl:value-of select="$end"/>
388 <xsl:text>,</xsl:text>
392 <xsl:variable name="end">
394 <xsl:when test="string-length($ends) > 0">
395 <xsl:value-of select="substring-before($ends,',')"/>
398 <xsl:text>1000</xsl:text>
402 <xsl:variable name="display">
403 <xsl:for-each select="../marc:subfield[position() > $start and position() < $end and @code!=2 and @code!=3]">
404 <xsl:value-of select="."/>
405 <xsl:if test="not(position()=last())">
406 <xsl:text>, </xsl:text>
411 <xsl:attribute name="href">
412 <xsl:text>/cgi-bin/koha/opac-search.pl?q=an:</xsl:text>
413 <xsl:value-of select="str:encode-uri(., true())"/>
416 <xsl:when test="string-length($display) > 0">
417 <xsl:call-template name="chopPunctuation">
418 <xsl:with-param name="chopString">
419 <xsl:value-of select="$display"/>
424 <xsl:value-of select="."/>
428 <xsl:variable name="ncommas"
429 select="string-length($ends) - string-length(translate($ends, ',', ''))" />
430 <xsl:if test="$ncommas > 1">
431 <xsl:text> -- </xsl:text>
436 <xsl:when test="marc:subfield[@code='a']">
438 <xsl:attribute name="href">
439 <xsl:text>/cgi-bin/koha/opac-search.pl?q=su:</xsl:text>
440 <xsl:value-of select="str:encode-uri(marc:subfield[@code='a'], true())"/>
442 <xsl:call-template name="chopPunctuation">
443 <xsl:with-param name="chopString">
444 <xsl:call-template name="subfieldSelect">
445 <xsl:with-param name="codes">abcdfijkmnptvxyz</xsl:with-param>
446 <xsl:with-param name="subdivCodes">ijknpxyz</xsl:with-param>
447 <xsl:with-param name="subdivDelimiter">-- </xsl:with-param>
455 <xsl:if test="not(position()=last())">
456 <xsl:text> | </xsl:text>
460 <xsl:template name="tag_subject">
461 <xsl:param name="tag" />
462 <xsl:param name="label" />
463 <xsl:param name="spanclass" />
464 <xsl:if test="marc:datafield[@tag=$tag]">
465 <span class="results_summary subjects {$spanclass}">
467 <xsl:value-of select="$label"/>
468 <xsl:text>: </xsl:text>
471 <xsl:for-each select="marc:datafield[@tag=$tag]">
472 <xsl:call-template name="tag_onesubject">
480 <xsl:template name="tag_7xx">
481 <xsl:param name="tag" />
482 <xsl:param name="label" />
483 <xsl:param name="spanclass" />
484 <xsl:variable name="IdRef" select="marc:sysprefs/marc:syspref[@name='IdRef']"/>
485 <xsl:if test="marc:datafield[@tag=$tag]">
486 <span class="results_summary author {$spanclass}">
488 <xsl:value-of select="$label" />
489 <xsl:text>: </xsl:text>
492 <xsl:for-each select="marc:datafield[@tag=$tag]">
495 <xsl:when test="marc:subfield[@code=9]">
496 <xsl:attribute name="href">
497 <xsl:text>/cgi-bin/koha/opac-search.pl?q=an:</xsl:text>
498 <xsl:value-of select="str:encode-uri(marc:subfield[@code=9], true())"/>
502 <xsl:attribute name="href">
503 <xsl:text>/cgi-bin/koha/opac-search.pl?q=au:</xsl:text>
504 <xsl:value-of select="str:encode-uri(marc:subfield[@code='a'], true())"/>
505 <xsl:text>%20</xsl:text>
506 <xsl:value-of select="str:encode-uri(marc:subfield[@code='b'], true())"/>
510 <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']">
512 <xsl:when test="@code='9'">
515 <xsl:value-of select="."/>
518 <xsl:if test="not(position() = last())">
519 <xsl:text>, </xsl:text>
523 <xsl:if test="$IdRef = '1'">
524 <xsl:if test="marc:subfield[@code=3]">
525 <xsl:text> </xsl:text>
527 <xsl:attribute name="href">
528 <xsl:text>/cgi-bin/koha/opac-idref.pl?unimarc3=</xsl:text>
529 <xsl:value-of select="str:encode-uri(marc:subfield[@code=3], true())"/>
531 <xsl:attribute name="title">IdRef</xsl:attribute>
532 <xsl:attribute name="rel">gb_page_center[600,500]</xsl:attribute>
533 <xsl:text>Idref</xsl:text>
537 <xsl:if test="not(position() = last())">
538 <span style="padding: 3px;">
539 <xsl:text>;</xsl:text>