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 exclude-result-prefixes="marc items">
11 <xsl:template name="datafield">
12 <xsl:param name="tag"/>
13 <xsl:param name="ind1"><xsl:text> </xsl:text></xsl:param>
14 <xsl:param name="ind2"><xsl:text> </xsl:text></xsl:param>
15 <xsl:param name="subfields"/>
16 <xsl:element name="datafield">
17 <xsl:attribute name="tag">
18 <xsl:value-of select="$tag"/>
20 <xsl:attribute name="ind1">
21 <xsl:value-of select="$ind1"/>
23 <xsl:attribute name="ind2">
24 <xsl:value-of select="$ind2"/>
26 <xsl:copy-of select="$subfields"/>
30 <xsl:template name="subfieldSelect">
31 <xsl:param name="codes"/>
32 <xsl:param name="delimeter"><xsl:text> </xsl:text></xsl:param>
33 <xsl:param name="subdivCodes"/>
34 <xsl:param name="subdivDelimiter"/>
35 <xsl:variable name="str">
36 <xsl:for-each select="marc:subfield">
37 <xsl:if test="contains($codes, @code)">
38 <xsl:if test="contains($subdivCodes, @code)">
39 <xsl:value-of select="$subdivDelimiter"/>
41 <xsl:value-of select="text()"/><xsl:value-of select="$delimeter"/>
45 <xsl:value-of select="substring($str,1,string-length($str)-string-length($delimeter))"/>
48 <xsl:template name="buildSpaces">
49 <xsl:param name="spaces"/>
50 <xsl:param name="char"><xsl:text> </xsl:text></xsl:param>
51 <xsl:if test="$spaces>0">
52 <xsl:value-of select="$char"/>
53 <xsl:call-template name="buildSpaces">
54 <xsl:with-param name="spaces" select="$spaces - 1"/>
55 <xsl:with-param name="char" select="$char"/>
60 <xsl:template name="buildBiblioDefaultViewURL">
61 <xsl:param name="BiblioDefaultView"/>
63 <xsl:when test="$BiblioDefaultView='normal'">
64 <xsl:text>/cgi-bin/koha/opac-detail.pl?biblionumber=</xsl:text>
66 <xsl:when test="$BiblioDefaultView='isbd'">
67 <xsl:text>/cgi-bin/koha/opac-ISBDdetail.pl?biblionumber=</xsl:text>
69 <xsl:when test="$BiblioDefaultView='marc'">
70 <xsl:text>/cgi-bin/koha/opac-MARCdetail.pl?biblionumber=</xsl:text>
73 <xsl:text>/cgi-bin/koha/opac-detail.pl?biblionumber=</xsl:text>
79 <xsl:template name="chopPunctuation">
80 <xsl:param name="chopString"/>
81 <xsl:variable name="length" select="string-length($chopString)"/>
83 <xsl:when test="$length=0"/>
84 <xsl:when test="contains('.:,;/ ', substring($chopString,$length,1))">
85 <xsl:call-template name="chopPunctuation">
86 <xsl:with-param name="chopString" select="substring($chopString,1,$length - 1)"/>
89 <xsl:when test="not($chopString)"/>
90 <xsl:otherwise><xsl:value-of select="$chopString"/></xsl:otherwise>
92 <xsl:text> </xsl:text>
95 <xsl:template name="addClassRtl">
96 <xsl:variable name="lang" select="marc:subfield[@code='7']" />
97 <xsl:if test="$lang = 'ha' or $lang = 'Hebrew' or $lang = 'fa' or $lang = 'Arabe'">
98 <xsl:attribute name="class">rtl</xsl:attribute>
102 <xsl:template name="tag_title">
103 <xsl:param name="tag" />
104 <xsl:param name="label" />
105 <xsl:param name="spanclass" />
106 <xsl:if test="marc:datafield[@tag=$tag]">
107 <span class="results_summary {$spanclass}">
109 <xsl:value-of select="$label"/>: </span>
110 <xsl:for-each select="marc:datafield[@tag=$tag]">
111 <xsl:call-template name="addClassRtl" />
112 <xsl:for-each select="marc:subfield">
114 <xsl:when test="@code='a'">
115 <xsl:variable name="title" select="."/>
116 <xsl:variable name="ntitle"
117 select="translate($title, 'ˆ‰˜œ','')"/>
118 <xsl:value-of select="$ntitle" />
120 <xsl:when test="@code='b'">
121 <xsl:text>[</xsl:text>
122 <xsl:value-of select="."/>
123 <xsl:text>]</xsl:text>
125 <xsl:when test="@code='d'">
126 <xsl:text> = </xsl:text>
127 <xsl:value-of select="."/>
129 <xsl:when test="@code='e'">
130 <xsl:text> : </xsl:text>
131 <xsl:value-of select="."/>
133 <xsl:when test="@code='f'">
134 <xsl:text> / </xsl:text>
135 <xsl:value-of select="."/>
137 <xsl:when test="@code='g'">
138 <xsl:text> ; </xsl:text>
139 <xsl:value-of select="."/>
142 <xsl:if test="position()>1">
143 <xsl:text>, </xsl:text>
145 <xsl:value-of select="."/>
149 <xsl:if test="not (position() = last())">
150 <xsl:text> • </xsl:text>
157 <xsl:template name="tag_comma">
158 <xsl:param name="tag" />
159 <xsl:param name="label" />
160 <xsl:param name="spanclass" />
161 <xsl:if test="marc:datafield[@tag=$tag]">
162 <span class="results_summary {$spanclass}">
164 <xsl:value-of select="$label"/>: </span>
165 <xsl:for-each select="marc:datafield[@tag=$tag]">
166 <xsl:call-template name="addClassRtl" />
167 <xsl:for-each select="marc:subfield">
168 <xsl:if test="position()>1">
169 <xsl:text>, </xsl:text>
171 <xsl:value-of select="."/>
173 <xsl:if test="not (position() = last())">
174 <xsl:text> • </xsl:text>
181 <xsl:template name="tag_210">
182 <span class="results_summary publication">
183 <span class="label">Publication: </span>
184 <xsl:for-each select="marc:datafield[@tag=210]">
186 <xsl:call-template name="addClassRtl" />
187 <xsl:for-each select="marc:subfield">
189 <xsl:when test="@code='c' or @code='g'">
190 <xsl:if test="position()>1">
191 <xsl:text> : </xsl:text>
193 <xsl:value-of select="."/>
196 <xsl:if test="position()>1">
197 <xsl:text>, </xsl:text>
199 <xsl:value-of select="."/>
203 <xsl:if test="not (position() = last())">
204 <xsl:text> • </xsl:text>
211 <xsl:template name="tag_215">
212 <xsl:for-each select="marc:datafield[@tag=215]">
213 <span class="results_summary description">
214 <span class="label">Description: </span>
215 <xsl:if test="marc:subfield[@code='a']">
216 <xsl:value-of select="marc:subfield[@code='a']"/>
218 <xsl:if test="marc:subfield[@code='c']"> :
219 <xsl:value-of select="marc:subfield[@code='c']"/>
221 <xsl:if test="marc:subfield[@code='d']"> ;
222 <xsl:value-of select="marc:subfield[@code='d']"/>
224 <xsl:if test="marc:subfield[@code='e']"> +
225 <xsl:value-of select="marc:subfield[@code='e']"/>
231 <xsl:template name="tag_onesubject">
233 <xsl:when test="marc:subfield[@code=9]">
234 <xsl:for-each select="marc:subfield">
235 <xsl:if test="@code='9'">
236 <xsl:variable name="start" select="position()"/>
237 <xsl:variable name="ends">
238 <xsl:for-each select="../marc:subfield[position() > $start]">
239 <xsl:if test="@code=9">
240 <xsl:variable name="end" select="position() + $start"/>
241 <xsl:value-of select="$end"/>
242 <xsl:text>,</xsl:text>
246 <xsl:variable name="end">
248 <xsl:when test="string-length($ends) > 0">
249 <xsl:value-of select="substring-before($ends,',')"/>
252 <xsl:text>1000</xsl:text>
256 <xsl:variable name="display">
257 <xsl:for-each select="../marc:subfield[position() > $start and position() < $end and @code!=2 and @code!=3]">
258 <xsl:value-of select="."/>
259 <xsl:if test="not(position()=last())">
260 <xsl:text>, </xsl:text>
265 <xsl:attribute name="href">
266 <xsl:text>/cgi-bin/koha/opac-search.pl?q=an:</xsl:text>
267 <xsl:value-of select="."/>
270 <xsl:when test="string-length($display) > 0">
271 <xsl:call-template name="chopPunctuation">
272 <xsl:with-param name="chopString">
273 <xsl:value-of select="$display"/>
278 <xsl:value-of select="."/>
282 <xsl:variable name="ncommas"
283 select="string-length($ends) - string-length(translate($ends, ',', ''))" />
284 <xsl:if test="$ncommas > 1">
285 <xsl:text> -- </xsl:text>
290 <xsl:when test="marc:subfield[@code='a']">
292 <xsl:attribute name="href">
293 <xsl:text>/cgi-bin/koha/opac-search.pl?q=su:</xsl:text>
294 <xsl:value-of select="marc:subfield[@code='a']"/>
296 <xsl:call-template name="chopPunctuation">
297 <xsl:with-param name="chopString">
298 <xsl:call-template name="subfieldSelect">
299 <xsl:with-param name="codes">abcdfijkmnpvxyz</xsl:with-param>
300 <xsl:with-param name="subdivCodes">ijknpxyz</xsl:with-param>
301 <xsl:with-param name="subdivDelimiter">-- </xsl:with-param>
309 <xsl:if test="not(position()=last())">
310 <xsl:text> | </xsl:text>
314 <xsl:template name="tag_subject">
315 <xsl:param name="tag" />
316 <xsl:param name="label" />
317 <xsl:param name="spanclass" />
318 <xsl:if test="marc:datafield[@tag=$tag]">
319 <span class="results_summary subjects {$spanclass}">
321 <xsl:value-of select="$label"/>
322 <xsl:text>: </xsl:text>
325 <xsl:for-each select="marc:datafield[@tag=$tag]">
326 <xsl:call-template name="tag_onesubject">
334 <xsl:template name="tag_7xx">
335 <xsl:param name="tag" />
336 <xsl:param name="label" />
337 <xsl:param name="spanclass" />
338 <xsl:variable name="IdRef" select="marc:sysprefs/marc:syspref[@name='IdRef']"/>
339 <xsl:if test="marc:datafield[@tag=$tag]">
340 <span class="results_summary author {$spanclass}">
342 <xsl:value-of select="$label" />
343 <xsl:text>: </xsl:text>
346 <xsl:for-each select="marc:datafield[@tag=$tag]">
349 <xsl:when test="marc:subfield[@code=9]">
350 <xsl:attribute name="href">
351 <xsl:text>/cgi-bin/koha/opac-search.pl?q=an:</xsl:text>
352 <xsl:value-of select="marc:subfield[@code=9]"/>
356 <xsl:attribute name="href">
357 <xsl:text>/cgi-bin/koha/opac-search.pl?q=au:</xsl:text>
358 <xsl:value-of select="marc:subfield[@code='a']"/>
359 <xsl:text> </xsl:text>
360 <xsl:value-of select="marc:subfield[@code='b']"/>
364 <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']">
366 <xsl:when test="@code='9'">
369 <xsl:value-of select="."/>
372 <xsl:if test="not(position() = last())">
373 <xsl:text>, </xsl:text>
377 <xsl:if test="$IdRef">
378 <xsl:if test="marc:subfield[@code=3]">
379 <xsl:text> </xsl:text>
381 <xsl:attribute name="href">
382 <xsl:text>/cgi-bin/koha/opac-idref.pl?unimarc3=</xsl:text>
383 <xsl:value-of select="marc:subfield[@code=3]"/>
385 <xsl:attribute name="title">IdRef</xsl:attribute>
386 <xsl:attribute name="rel">gb_page_center[600,500]</xsl:attribute>
387 <xsl:text>Idref</xsl:text>
391 <xsl:if test="not(position() = last())">
392 <span style="padding: 3px;">
393 <xsl:text>;</xsl:text>