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:if test="marc:datafield[@tag=$tag]">
87 <span class="results_summary">
89 <xsl:value-of select="$label"/>: </span>
90 <xsl:for-each select="marc:datafield[@tag=$tag]">
91 <xsl:call-template name="addClassRtl" />
92 <xsl:for-each select="marc:subfield">
94 <xsl:when test="@code='a'">
95 <xsl:variable name="title" select="."/>
96 <xsl:variable name="ntitle"
97 select="translate($title, 'ˆ‰˜œ','')"/>
98 <xsl:value-of select="$ntitle" />
100 <xsl:when test="@code='b'">
101 <xsl:text>[</xsl:text>
102 <xsl:value-of select="."/>
103 <xsl:text>]</xsl:text>
105 <xsl:when test="@code='d'">
106 <xsl:text> = </xsl:text>
107 <xsl:value-of select="."/>
109 <xsl:when test="@code='e'">
110 <xsl:text> : </xsl:text>
111 <xsl:value-of select="."/>
113 <xsl:when test="@code='f'">
114 <xsl:text> / </xsl:text>
115 <xsl:value-of select="."/>
117 <xsl:when test="@code='g'">
118 <xsl:text> ; </xsl:text>
119 <xsl:value-of select="."/>
122 <xsl:if test="position()>1">
123 <xsl:text>, </xsl:text>
125 <xsl:value-of select="."/>
129 <xsl:if test="not (position() = last())">
130 <xsl:text> • </xsl:text>
137 <xsl:template name="tag_comma">
138 <xsl:param name="tag" />
139 <xsl:param name="label" />
140 <xsl:if test="marc:datafield[@tag=$tag]">
141 <span class="results_summary">
143 <xsl:value-of select="$label"/>: </span>
144 <xsl:for-each select="marc:datafield[@tag=$tag]">
145 <xsl:call-template name="addClassRtl" />
146 <xsl:for-each select="marc:subfield">
147 <xsl:if test="position()>1">
148 <xsl:text>, </xsl:text>
150 <xsl:value-of select="."/>
152 <xsl:if test="not (position() = last())">
153 <xsl:text> • </xsl:text>
160 <xsl:template name="tag_210">
161 <span class="results_summary">
162 <span class="label">Publication:</span>
163 <xsl:for-each select="marc:datafield[@tag=210]">
165 <xsl:call-template name="addClassRtl" />
166 <xsl:for-each select="marc:subfield">
168 <xsl:when test="@code='c' or @code='g'">
169 <xsl:if test="position()>1">
170 <xsl:text> : </xsl:text>
172 <xsl:value-of select="."/>
175 <xsl:if test="position()>1">
176 <xsl:text>, </xsl:text>
178 <xsl:value-of select="."/>
182 <xsl:if test="not (position() = last())">
183 <xsl:text> • </xsl:text>
190 <xsl:template name="tag_215">
191 <xsl:for-each select="marc:datafield[@tag=215]">
192 <span class="results_summary">
193 <span class="label">Description: </span>
194 <xsl:if test="marc:subfield[@code='a']">
195 <xsl:value-of select="marc:subfield[@code='a']"/>
197 <xsl:if test="marc:subfield[@code='c']"> :
198 <xsl:value-of select="marc:subfield[@code='c']"/>
200 <xsl:if test="marc:subfield[@code='d']"> ;
201 <xsl:value-of select="marc:subfield[@code='d']"/>
203 <xsl:if test="marc:subfield[@code='e']"> +
204 <xsl:value-of select="marc:subfield[@code='e']"/>
210 <xsl:template name="tag_onesubject">
212 <xsl:when test="marc:subfield[@code=9]">
213 <xsl:for-each select="marc:subfield">
214 <xsl:if test="@code='9'">
215 <xsl:variable name="start" select="position()"/>
216 <xsl:variable name="ends">
217 <xsl:for-each select="../marc:subfield[position() > $start]">
218 <xsl:if test="@code=9">
219 <xsl:variable name="end" select="position() + $start"/>
220 <xsl:value-of select="$end"/>
221 <xsl:text>,</xsl:text>
225 <xsl:variable name="end">
227 <xsl:when test="string-length($ends) > 0">
228 <xsl:value-of select="substring-before($ends,',')"/>
231 <xsl:text>1000</xsl:text>
235 <xsl:variable name="display">
236 <xsl:for-each select="../marc:subfield[position() > $start and position() < $end and @code!=2 and @code!=3]">
237 <xsl:value-of select="."/>
238 <xsl:if test="not(position()=last())">
239 <xsl:text>, </xsl:text>
244 <xsl:attribute name="href">
245 <xsl:text>/cgi-bin/koha/opac-search.pl?q=an:</xsl:text>
246 <xsl:value-of select="."/>
249 <xsl:when test="string-length($display) > 0">
250 <xsl:call-template name="chopPunctuation">
251 <xsl:with-param name="chopString">
252 <xsl:value-of select="$display"/>
257 <xsl:value-of select="."/>
261 <xsl:variable name="ncommas"
262 select="string-length($ends) - string-length(translate($ends, ',', ''))" />
263 <xsl:if test="$ncommas > 1">
264 <xsl:text> -- </xsl:text>
269 <xsl:when test="marc:subfield[@code=a]">
271 <xsl:attribute name="href">
272 <xsl:text>/cgi-bin/koha/opac-search.pl?q=su:</xsl:text>
273 <xsl:value-of select="marc:subfield[@code='a']"/>
275 <xsl:call-template name="chopPunctuation">
276 <xsl:with-param name="chopString">
277 <xsl:call-template name="subfieldSelect">
278 <xsl:with-param name="codes">abcdfijkmnpvxyz</xsl:with-param>
279 <xsl:with-param name="subdivCodes">ijknpxyz</xsl:with-param>
280 <xsl:with-param name="subdivDelimiter">-- </xsl:with-param>
288 <xsl:if test="not(position()=last())">
289 <xsl:text> | </xsl:text>
293 <xsl:template name="tag_subject">
294 <xsl:param name="tag" />
295 <xsl:param name="label" />
296 <xsl:if test="marc:datafield[@tag=$tag]">
297 <span class="results_summary">
299 <xsl:value-of select="$label"/>
300 <xsl:text>: </xsl:text>
303 <xsl:for-each select="marc:datafield[@tag=$tag]">
304 <xsl:call-template name="tag_onesubject">
312 <xsl:template name="tag_7xx">
313 <xsl:param name="tag" />
314 <xsl:param name="label" />
315 <xsl:if test="marc:datafield[@tag=$tag]">
316 <span class="results_summary">
318 <xsl:value-of select="$label" />
319 <xsl:text>: </xsl:text>
322 <xsl:for-each select="marc:datafield[@tag=$tag]">
325 <xsl:when test="marc:subfield[@code=9]">
326 <xsl:attribute name="href">
327 <xsl:text>/cgi-bin/koha/opac-search.pl?q=an:</xsl:text>
328 <xsl:value-of select="marc:subfield[@code=9]"/>
332 <xsl:attribute name="href">
333 <xsl:text>/cgi-bin/koha/opac-search.pl?q=au:</xsl:text>
334 <xsl:value-of select="marc:subfield[@code='a']"/>
335 <xsl:text> </xsl:text>
336 <xsl:value-of select="marc:subfield[@code='b']"/>
340 <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']">
342 <xsl:when test="@code='9'">
345 <xsl:value-of select="."/>
348 <xsl:if test="not(position() = last())">
349 <xsl:text>, </xsl:text>
353 <xsl:if test="not(position() = last())">
354 <span style="padding: 3px;">
355 <xsl:text>;</xsl:text>