3 <!DOCTYPE stylesheet [<!ENTITY nbsp " " >]>
5 <xsl:stylesheet version="1.0"
6 xmlns:marc="http://www.loc.gov/MARC21/slim"
7 xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
8 exclude-result-prefixes="marc items">
10 <xsl:template name="datafield">
11 <xsl:param name="tag"/>
12 <xsl:param name="ind1"><xsl:text> </xsl:text></xsl:param>
13 <xsl:param name="ind2"><xsl:text> </xsl:text></xsl:param>
14 <xsl:param name="subfields"/>
15 <xsl:element name="datafield">
16 <xsl:attribute name="tag">
17 <xsl:value-of select="$tag"/>
19 <xsl:attribute name="ind1">
20 <xsl:value-of select="$ind1"/>
22 <xsl:attribute name="ind2">
23 <xsl:value-of select="$ind2"/>
25 <xsl:copy-of select="$subfields"/>
29 <xsl:template name="subfieldSelect">
30 <xsl:param name="codes"/>
31 <xsl:param name="delimeter"><xsl:text> </xsl:text></xsl:param>
32 <xsl:param name="subdivCodes"/>
33 <xsl:param name="subdivDelimiter"/>
34 <xsl:variable name="str">
35 <xsl:for-each select="marc:subfield">
36 <xsl:if test="contains($codes, @code)">
37 <xsl:if test="contains($subdivCodes, @code)">
38 <xsl:value-of select="$subdivDelimiter"/>
40 <xsl:value-of select="text()"/><xsl:value-of select="$delimeter"/>
44 <xsl:value-of select="substring($str,1,string-length($str)-string-length($delimeter))"/>
47 <xsl:template name="buildSpaces">
48 <xsl:param name="spaces"/>
49 <xsl:param name="char"><xsl:text> </xsl:text></xsl:param>
50 <xsl:if test="$spaces>0">
51 <xsl:value-of select="$char"/>
52 <xsl:call-template name="buildSpaces">
53 <xsl:with-param name="spaces" select="$spaces - 1"/>
54 <xsl:with-param name="char" select="$char"/>
59 <xsl:template name="chopPunctuation">
60 <xsl:param name="chopString"/>
61 <xsl:variable name="length" select="string-length($chopString)"/>
63 <xsl:when test="$length=0"/>
64 <xsl:when test="contains('.:,;/ ', substring($chopString,$length,1))">
65 <xsl:call-template name="chopPunctuation">
66 <xsl:with-param name="chopString" select="substring($chopString,1,$length - 1)"/>
69 <xsl:when test="not($chopString)"/>
70 <xsl:otherwise><xsl:value-of select="$chopString"/></xsl:otherwise>
72 <xsl:text> </xsl:text>
75 <xsl:template name="addClassRtl">
76 <xsl:variable name="lang" select="marc:subfield[@code='7']" />
77 <xsl:if test="$lang = 'ha' or $lang = 'Hebrew' or $lang = 'fa' or $lang = 'Arabe'">
78 <xsl:attribute name="class">rtl</xsl:attribute>
82 <xsl:template name="tag_title">
83 <xsl:param name="tag" />
84 <xsl:param name="label" />
85 <xsl:if test="marc:datafield[@tag=$tag]">
86 <span class="results_summary">
88 <xsl:value-of select="$label"/>: </span>
89 <xsl:for-each select="marc:datafield[@tag=$tag]">
90 <xsl:call-template name="addClassRtl" />
91 <xsl:for-each select="marc:subfield">
93 <xsl:when test="@code='a'">
94 <xsl:variable name="title" select="."/>
95 <xsl:variable name="ntitle"
96 select="translate($title, 'ˆ‰˜œ','')"/>
97 <xsl:value-of select="$ntitle" />
99 <xsl:when test="@code='b'">
100 <xsl:text>[</xsl:text>
101 <xsl:value-of select="."/>
102 <xsl:text>]</xsl:text>
104 <xsl:when test="@code='d'">
105 <xsl:text> = </xsl:text>
106 <xsl:value-of select="."/>
108 <xsl:when test="@code='e'">
109 <xsl:text> : </xsl:text>
110 <xsl:value-of select="."/>
112 <xsl:when test="@code='f'">
113 <xsl:text> / </xsl:text>
114 <xsl:value-of select="."/>
116 <xsl:when test="@code='g'">
117 <xsl:text> ; </xsl:text>
118 <xsl:value-of select="."/>
121 <xsl:if test="position()>1">
122 <xsl:text>, </xsl:text>
124 <xsl:value-of select="."/>
128 <xsl:if test="not (position() = last())">
129 <xsl:text> • </xsl:text>
136 <xsl:template name="tag_comma">
137 <xsl:param name="tag" />
138 <xsl:param name="label" />
139 <xsl:if test="marc:datafield[@tag=$tag]">
140 <span class="results_summary">
142 <xsl:value-of select="$label"/>: </span>
143 <xsl:for-each select="marc:datafield[@tag=$tag]">
144 <xsl:call-template name="addClassRtl" />
145 <xsl:for-each select="marc:subfield">
146 <xsl:if test="position()>1">
147 <xsl:text>, </xsl:text>
149 <xsl:value-of select="."/>
151 <xsl:if test="not (position() = last())">
152 <xsl:text> • </xsl:text>
159 <xsl:template name="tag_210">
160 <span class="results_summary">
161 <span class="label">Publication:</span>
162 <xsl:for-each select="marc:datafield[@tag=210]">
164 <xsl:call-template name="addClassRtl" />
165 <xsl:for-each select="marc:subfield">
167 <xsl:when test="@code='c' or @code='g'">
168 <xsl:if test="position()>1">
169 <xsl:text> : </xsl:text>
171 <xsl:value-of select="."/>
174 <xsl:if test="position()>1">
175 <xsl:text>, </xsl:text>
177 <xsl:value-of select="."/>
181 <xsl:if test="not (position() = last())">
182 <xsl:text> • </xsl:text>
189 <xsl:template name="tag_215">
190 <xsl:for-each select="marc:datafield[@tag=215]">
191 <span class="results_summary">
192 <span class="label">Description: </span>
193 <xsl:if test="marc:subfield[@code='a']">
194 <xsl:value-of select="marc:subfield[@code='a']"/>
196 <xsl:if test="marc:subfield[@code='c']"> :
197 <xsl:value-of select="marc:subfield[@code='c']"/>
199 <xsl:if test="marc:subfield[@code='d']"> ;
200 <xsl:value-of select="marc:subfield[@code='d']"/>
202 <xsl:if test="marc:subfield[@code='e']"> +
203 <xsl:value-of select="marc:subfield[@code='e']"/>
209 <xsl:template name="tag_onesubject">
211 <xsl:when test="marc:subfield[@code=9]">
212 <xsl:for-each select="marc:subfield">
213 <xsl:if test="@code='9'">
214 <xsl:variable name="start" select="position()"/>
215 <xsl:variable name="ends">
216 <xsl:for-each select="../marc:subfield[position() > $start]">
217 <xsl:if test="@code=3 or @code=9 or @code=2">
218 <xsl:variable name="end" select="position() + $start"/>
219 <xsl:value-of select="$end"/>
220 <xsl:text>,</xsl:text>
224 <xsl:variable name="end">
226 <xsl:when test="string-length($ends) > 0">
227 <xsl:value-of select="substring-before($ends,',')"/>
230 <xsl:text>1000</xsl:text>
234 <xsl:variable name="display">
235 <xsl:for-each select="../marc:subfield[position() > $start and position() < $end]">
236 <xsl:value-of select="."/>
237 <xsl:if test="not(position()=last())">
238 <xsl:text>, </xsl:text>
243 <xsl:attribute name="href">
244 <xsl:text>/cgi-bin/koha/opac-search.pl?q=an:</xsl:text>
245 <xsl:value-of select="."/>
247 <xsl:value-of select="$display"/>
249 <xsl:variable name="ncommas"
250 select="string-length($ends) - string-length(translate($ends, ',', ''))" />
251 <xsl:if test="$ncommas > 1">
252 <xsl:text> -- </xsl:text>
259 <xsl:attribute name="href">
260 <xsl:text>/cgi-bin/koha/opac-search.pl?q=su:</xsl:text>
261 <xsl:value-of select="marc:subfield[@code='a']"/>
263 <xsl:call-template name="chopPunctuation">
264 <xsl:with-param name="chopString">
265 <xsl:call-template name="subfieldSelect">
266 <xsl:with-param name="codes">abcdfijkmnpvxyz</xsl:with-param>
267 <xsl:with-param name="subdivCodes">ijknpxyz</xsl:with-param>
268 <xsl:with-param name="subdivDelimiter">-- </xsl:with-param>
275 <xsl:if test="not(position()=last())">
276 <xsl:text> | </xsl:text>
280 <xsl:template name="tag_subject">
281 <xsl:param name="tag" />
282 <xsl:param name="label" />
283 <xsl:if test="marc:datafield[@tag=$tag]">
284 <span class="results_summary">
286 <xsl:value-of select="$label"/>
287 <xsl:text>: </xsl:text>
290 <xsl:for-each select="marc:datafield[@tag=$tag]">
291 <xsl:call-template name="tag_onesubject">
299 <xsl:template name="tag_7xx">
300 <xsl:param name="tag" />
301 <xsl:param name="label" />
302 <xsl:if test="marc:datafield[@tag=$tag]">
303 <span class="results_summary">
305 <xsl:value-of select="$label" />
306 <xsl:text>: </xsl:text>
309 <xsl:for-each select="marc:datafield[@tag=$tag]">
312 <xsl:when test="marc:subfield[@code=9]">
313 <xsl:attribute name="href">
314 <xsl:text>/cgi-bin/koha/opac-search.pl?q=an:</xsl:text>
315 <xsl:value-of select="marc:subfield[@code=9]"/>
319 <xsl:attribute name="href">
320 <xsl:text>/cgi-bin/koha/opac-search.pl?q=au:</xsl:text>
321 <xsl:value-of select="marc:subfield[@code='a']"/>
322 <xsl:text> </xsl:text>
323 <xsl:value-of select="marc:subfield[@code='b']"/>
327 <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']">
329 <xsl:when test="@code='9'">
332 <xsl:value-of select="."/>
335 <xsl:if test="not(position() = last())">
336 <xsl:text>, </xsl:text>
340 <xsl:if test="not(position() = last())">
341 <span style="padding: 3px;">
342 <xsl:text>;</xsl:text>