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="chopPunctuation">
61 <xsl:param name="chopString"/>
62 <xsl:variable name="length" select="string-length($chopString)"/>
64 <xsl:when test="$length=0"/>
65 <xsl:when test="contains('.:,;/ ', substring($chopString,$length,1))">
66 <xsl:call-template name="chopPunctuation">
67 <xsl:with-param name="chopString" select="substring($chopString,1,$length - 1)"/>
70 <xsl:when test="not($chopString)"/>
71 <xsl:otherwise><xsl:value-of select="$chopString"/></xsl:otherwise>
73 <xsl:text> </xsl:text>
76 <xsl:template name="addClassRtl">
77 <xsl:variable name="lang" select="marc:subfield[@code='7']" />
78 <xsl:if test="$lang = 'ha' or $lang = 'Hebrew' or $lang = 'fa' or $lang = 'Arabe'">
79 <xsl:attribute name="class">rtl</xsl:attribute>
83 <xsl:template name="tag_title">
84 <xsl:param name="tag" />
85 <xsl:param name="label" />
86 <xsl:param name="spanclass" />
87 <xsl:if test="marc:datafield[@tag=$tag]">
88 <span class="results_summary {$spanclass}">
90 <xsl:value-of select="$label"/>: </span>
91 <xsl:for-each select="marc:datafield[@tag=$tag]">
92 <xsl:call-template name="addClassRtl" />
93 <xsl:for-each select="marc:subfield">
95 <xsl:when test="@code='a'">
96 <xsl:variable name="title" select="."/>
97 <xsl:variable name="ntitle"
98 select="translate($title, 'ˆ‰˜œ','')"/>
99 <xsl:value-of select="$ntitle" />
101 <xsl:when test="@code='b'">
102 <xsl:text>[</xsl:text>
103 <xsl:value-of select="."/>
104 <xsl:text>]</xsl:text>
106 <xsl:when test="@code='d'">
107 <xsl:text> = </xsl:text>
108 <xsl:value-of select="."/>
110 <xsl:when test="@code='e'">
111 <xsl:text> : </xsl:text>
112 <xsl:value-of select="."/>
114 <xsl:when test="@code='f'">
115 <xsl:text> / </xsl:text>
116 <xsl:value-of select="."/>
118 <xsl:when test="@code='g'">
119 <xsl:text> ; </xsl:text>
120 <xsl:value-of select="."/>
123 <xsl:if test="position()>1">
124 <xsl:text>, </xsl:text>
126 <xsl:value-of select="."/>
130 <xsl:if test="not (position() = last())">
131 <xsl:text> • </xsl:text>
138 <xsl:template name="tag_comma">
139 <xsl:param name="tag" />
140 <xsl:param name="label" />
141 <xsl:param name="spanclass" />
142 <xsl:if test="marc:datafield[@tag=$tag]">
143 <span class="results_summary {$spanclass}">
145 <xsl:value-of select="$label"/>: </span>
146 <xsl:for-each select="marc:datafield[@tag=$tag]">
147 <xsl:call-template name="addClassRtl" />
148 <xsl:for-each select="marc:subfield">
149 <xsl:if test="position()>1">
150 <xsl:text>, </xsl:text>
152 <xsl:value-of select="."/>
154 <xsl:if test="not (position() = last())">
155 <xsl:text> • </xsl:text>
162 <xsl:template name="tag_210">
163 <span class="results_summary publication">
164 <span class="label">Publication: </span>
165 <xsl:for-each select="marc:datafield[@tag=210]">
167 <xsl:call-template name="addClassRtl" />
168 <xsl:for-each select="marc:subfield">
170 <xsl:when test="@code='c' or @code='g'">
171 <xsl:if test="position()>1">
172 <xsl:text> : </xsl:text>
174 <xsl:value-of select="."/>
177 <xsl:if test="position()>1">
178 <xsl:text>, </xsl:text>
180 <xsl:value-of select="."/>
184 <xsl:if test="not (position() = last())">
185 <xsl:text> • </xsl:text>
192 <xsl:template name="tag_215">
193 <xsl:for-each select="marc:datafield[@tag=215]">
194 <span class="results_summary description">
195 <span class="label">Description: </span>
196 <xsl:if test="marc:subfield[@code='a']">
197 <xsl:value-of select="marc:subfield[@code='a']"/>
199 <xsl:if test="marc:subfield[@code='c']"> :
200 <xsl:value-of select="marc:subfield[@code='c']"/>
202 <xsl:if test="marc:subfield[@code='d']"> ;
203 <xsl:value-of select="marc:subfield[@code='d']"/>
205 <xsl:if test="marc:subfield[@code='e']"> +
206 <xsl:value-of select="marc:subfield[@code='e']"/>
212 <xsl:template name="tag_onesubject">
214 <xsl:when test="marc:subfield[@code=9]">
215 <xsl:for-each select="marc:subfield">
216 <xsl:if test="@code='9'">
217 <xsl:variable name="start" select="position()"/>
218 <xsl:variable name="ends">
219 <xsl:for-each select="../marc:subfield[position() > $start]">
220 <xsl:if test="@code=9">
221 <xsl:variable name="end" select="position() + $start"/>
222 <xsl:value-of select="$end"/>
223 <xsl:text>,</xsl:text>
227 <xsl:variable name="end">
229 <xsl:when test="string-length($ends) > 0">
230 <xsl:value-of select="substring-before($ends,',')"/>
233 <xsl:text>1000</xsl:text>
237 <xsl:variable name="display">
238 <xsl:for-each select="../marc:subfield[position() > $start and position() < $end and @code!=2 and @code!=3]">
239 <xsl:value-of select="."/>
240 <xsl:if test="not(position()=last())">
241 <xsl:text>, </xsl:text>
246 <xsl:attribute name="href">
247 <xsl:text>/cgi-bin/koha/opac-search.pl?q=an:</xsl:text>
248 <xsl:value-of select="."/>
251 <xsl:when test="string-length($display) > 0">
252 <xsl:call-template name="chopPunctuation">
253 <xsl:with-param name="chopString">
254 <xsl:value-of select="$display"/>
259 <xsl:value-of select="."/>
263 <xsl:variable name="ncommas"
264 select="string-length($ends) - string-length(translate($ends, ',', ''))" />
265 <xsl:if test="$ncommas > 1">
266 <xsl:text> -- </xsl:text>
271 <xsl:when test="marc:subfield[@code='a']">
273 <xsl:attribute name="href">
274 <xsl:text>/cgi-bin/koha/opac-search.pl?q=su:</xsl:text>
275 <xsl:value-of select="marc:subfield[@code='a']"/>
277 <xsl:call-template name="chopPunctuation">
278 <xsl:with-param name="chopString">
279 <xsl:call-template name="subfieldSelect">
280 <xsl:with-param name="codes">abcdfijkmnpvxyz</xsl:with-param>
281 <xsl:with-param name="subdivCodes">ijknpxyz</xsl:with-param>
282 <xsl:with-param name="subdivDelimiter">-- </xsl:with-param>
290 <xsl:if test="not(position()=last())">
291 <xsl:text> | </xsl:text>
295 <xsl:template name="tag_subject">
296 <xsl:param name="tag" />
297 <xsl:param name="label" />
298 <xsl:param name="spanclass" />
299 <xsl:if test="marc:datafield[@tag=$tag]">
300 <span class="results_summary subjects {$spanclass}">
302 <xsl:value-of select="$label"/>
303 <xsl:text>: </xsl:text>
306 <xsl:for-each select="marc:datafield[@tag=$tag]">
307 <xsl:call-template name="tag_onesubject">
315 <xsl:template name="tag_7xx">
316 <xsl:param name="tag" />
317 <xsl:param name="label" />
318 <xsl:param name="spanclass" />
319 <xsl:if test="marc:datafield[@tag=$tag]">
320 <span class="results_summary author {$spanclass}">
322 <xsl:value-of select="$label" />
323 <xsl:text>: </xsl:text>
326 <xsl:for-each select="marc:datafield[@tag=$tag]">
329 <xsl:when test="marc:subfield[@code=9]">
330 <xsl:attribute name="href">
331 <xsl:text>/cgi-bin/koha/opac-search.pl?q=an:</xsl:text>
332 <xsl:value-of select="marc:subfield[@code=9]"/>
336 <xsl:attribute name="href">
337 <xsl:text>/cgi-bin/koha/opac-search.pl?q=au:</xsl:text>
338 <xsl:value-of select="marc:subfield[@code='a']"/>
339 <xsl:text> </xsl:text>
340 <xsl:value-of select="marc:subfield[@code='b']"/>
344 <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']">
346 <xsl:when test="@code='9'">
349 <xsl:value-of select="."/>
352 <xsl:if test="not(position() = last())">
353 <xsl:text>, </xsl:text>
357 <xsl:if test="not(position() = last())">
358 <span style="padding: 3px;">
359 <xsl:text>;</xsl:text>