Bug 5738 Display 856u As Image
[wip/koha-chris_n.git] / koha-tmpl / intranet-tmpl / prog / en / xslt / MARC21slim2intranetDetail.xsl
1 <?xml version="1.0" encoding="UTF-8"?>
2 <!-- $Id: MARC21slim2DC.xsl,v 1.1 2003/01/06 08:20:27 adam Exp $ -->
3 <xsl:stylesheet version="1.0"
4   xmlns:marc="http://www.loc.gov/MARC21/slim"
5   xmlns:items="http://www.koha-community.org/items"
6   xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
7   exclude-result-prefixes="marc items">
8     <xsl:import href="MARC21slimUtils.xsl"/>
9     <xsl:output method = "xml" indent="yes" omit-xml-declaration = "yes" />
10     <xsl:template match="/">
11             <xsl:apply-templates/>
12     </xsl:template>
13
14     <xsl:template match="marc:record">
15
16         <!-- Option: Display Alternate Graphic Representation (MARC 880)  -->
17         <xsl:variable name="display880" select="boolean(marc:datafield[@tag=880])"/>
18
19         <xsl:variable name="UseControlNumber" select="1"/>
20         <xsl:variable name="URLLinkText" select="marc:sysprefs/marc:syspref[@name='URLLinkText']"/>
21         <xsl:variable name="OPACBaseURL" select="marc:sysprefs/marc:syspref[@name='OPACBaseURL']"/>
22         <xsl:variable name="SubjectModifier"><xsl:if test="marc:sysprefs/marc:syspref[@name='TraceCompleteSubfields']='1'">,complete-subfield</xsl:if></xsl:variable>
23         <xsl:variable name="UseAuthoritiesForTracings" select="marc:sysprefs/marc:syspref[@name='UseAuthoritiesForTracings']"/>
24         <xsl:variable name="TraceSubjectSubdivisions" select="marc:sysprefs/marc:syspref[@name='TraceSubjectSubdivisions']"/>
25
26         <xsl:variable name="Show856uAsImage" select="marc:sysprefs/marc:syspref[@name='Display856uAsImage']"/>
27         <xsl:variable name="leader" select="marc:leader"/>
28         <xsl:variable name="leader6" select="substring($leader,7,1)"/>
29         <xsl:variable name="leader7" select="substring($leader,8,1)"/>
30         <xsl:variable name="leader19" select="substring($leader,20,1)"/>
31         <xsl:variable name="controlField008" select="marc:controlfield[@tag=008]"/>
32         <xsl:variable name="materialTypeCode">
33             <xsl:choose>
34                 <xsl:when test="$leader19='a'">ST</xsl:when>
35                 <xsl:when test="$leader6='a'">
36                     <xsl:choose>
37                         <xsl:when test="$leader7='c' or $leader7='d' or $leader7='m'">BK</xsl:when>
38                         <xsl:when test="$leader7='i' or $leader7='s'">SE</xsl:when>
39                         <xsl:when test="$leader7='a' or $leader7='b'">AR</xsl:when>
40                     </xsl:choose>
41                 </xsl:when>
42                 <xsl:when test="$leader6='t'">BK</xsl:when>
43                 <xsl:when test="$leader6='o' or $leader6='p'">MX</xsl:when>
44                 <xsl:when test="$leader6='m'">CF</xsl:when>
45                 <xsl:when test="$leader6='e' or $leader6='f'">MP</xsl:when>
46                 <xsl:when test="$leader6='g' or $leader6='k' or $leader6='r'">VM</xsl:when>
47                 <xsl:when test="$leader6='i' or $leader6='j'">MU</xsl:when>
48                 <xsl:when test="$leader6='c' or $leader6='d'">PR</xsl:when>
49             </xsl:choose>
50         </xsl:variable>
51         <xsl:variable name="materialTypeLabel">
52             <xsl:choose>
53                 <xsl:when test="$leader19='a'">Set</xsl:when>
54                 <xsl:when test="$leader6='a'">
55                     <xsl:choose>
56                         <xsl:when test="$leader7='c' or $leader7='d' or $leader7='m'">Book</xsl:when>
57                         <xsl:when test="$leader7='i' or $leader7='s'">
58                             <xsl:choose>
59                                 <xsl:when test="substring($controlField008,22,1)!='m'">Continuing Resource</xsl:when>
60                                 <xsl:otherwise>Series</xsl:otherwise>
61                             </xsl:choose>
62                         </xsl:when>
63                         <xsl:when test="$leader7='a' or $leader7='b'">Article</xsl:when>
64                     </xsl:choose>
65                 </xsl:when>
66                 <xsl:when test="$leader6='t'">Book</xsl:when>
67                 <xsl:when test="$leader6='o'">Kit</xsl:when>                            
68                 <xsl:when test="$leader6='p'">Mixed Materials</xsl:when>
69                 <xsl:when test="$leader6='m'">Computer File</xsl:when>
70                 <xsl:when test="$leader6='e' or $leader6='f'">Map</xsl:when>
71                 <xsl:when test="$leader6='g' or $leader6='k' or $leader6='r'">Visual Material</xsl:when>
72                 <xsl:when test="$leader6='j'">Music</xsl:when>
73                 <xsl:when test="$leader6='i'">Sound</xsl:when>
74                 <xsl:when test="$leader6='c' or $leader6='d'">Score</xsl:when>
75             </xsl:choose>
76         </xsl:variable>
77
78         <!-- Title Statement -->
79         <!-- Alternate Graphic Representation (MARC 880) -->
80         <xsl:if test="$display880">
81             <h1 class="title">
82                 <xsl:call-template name="m880Select">
83                     <xsl:with-param name="basetags">245</xsl:with-param>
84                     <xsl:with-param name="codes">abhfgknps</xsl:with-param>
85                 </xsl:call-template>
86             </h1>
87         </xsl:if>
88
89         <xsl:if test="marc:datafield[@tag=245]">
90         <h1>
91             <xsl:for-each select="marc:datafield[@tag=245]">
92                     <xsl:call-template name="subfieldSelect">
93                         <xsl:with-param name="codes">a</xsl:with-param>
94                     </xsl:call-template>
95                     <xsl:if test="marc:subfield[@code='b']">
96                         <xsl:text> </xsl:text>
97                         <xsl:call-template name="subfieldSelect">
98                             <xsl:with-param name="codes">b</xsl:with-param>
99                         </xsl:call-template>
100                     </xsl:if>
101                     <xsl:if test="marc:subfield[@code='h']">
102                         <xsl:text> </xsl:text>
103                         <xsl:call-template name="subfieldSelect">
104                             <xsl:with-param name="codes">h</xsl:with-param>
105                         </xsl:call-template>
106                     </xsl:if>
107                     <xsl:text> </xsl:text>
108                     <xsl:call-template name="subfieldSelect">
109                         <xsl:with-param name="codes">fgknps</xsl:with-param>
110                     </xsl:call-template>
111             </xsl:for-each>
112         </h1>
113         </xsl:if>
114
115         <!-- Author Statement: Alternate Graphic Representation (MARC 880) -->
116         <xsl:if test="$display880">
117             <h5 class="author">
118                 <xsl:call-template name="m880Select">
119                     <xsl:with-param name="basetags">100,110,111,700,710,711</xsl:with-param>
120                     <xsl:with-param name="codes">abc</xsl:with-param>
121                     <xsl:with-param name="index">au</xsl:with-param>
122                     <!-- do not use label 'by ' here, it would be repeated for every occurence of 100,110,111,700,710,711 -->
123                 </xsl:call-template>
124             </h5>
125         </xsl:if>
126
127         <!-- Author Statement -->
128         <xsl:call-template name="showAuthor"><xsl:with-param name="authorfield" select="marc:datafield[@tag=100 or @tag=110 or @tag=111]"/><xsl:with-param name="UseAuthoritiesForTracings" select="$UseAuthoritiesForTracings"/></xsl:call-template>
129         <xsl:call-template name="showAuthor"><xsl:with-param name="authorfield" select="marc:datafield[@tag=700 or @tag=710 or @tag=711]"/><xsl:with-param name="UseAuthoritiesForTracings" select="$UseAuthoritiesForTracings"/></xsl:call-template>
130
131    <xsl:if test="$materialTypeCode!=''">
132         <span class="results_summary"><span class="label">Type: </span>
133         <xsl:element name="img"><xsl:attribute name="src">/intranet-tmpl/prog/img/famfamfam/<xsl:value-of select="$materialTypeCode"/>.png</xsl:attribute><xsl:attribute name="alt"></xsl:attribute></xsl:element>
134         <xsl:text> </xsl:text>
135         <xsl:value-of select="$materialTypeLabel"/>
136         </span>
137    </xsl:if>
138
139         <!--Series: Alternate Graphic Representation (MARC 880) -->
140         <xsl:if test="$display880">
141             <xsl:call-template name="m880Select">
142                 <xsl:with-param name="basetags">440,490</xsl:with-param>
143                 <xsl:with-param name="codes">av</xsl:with-param>
144                 <xsl:with-param name="class">results_summary</xsl:with-param>
145                 <xsl:with-param name="label">Series: </xsl:with-param>
146                 <xsl:with-param name="index">se</xsl:with-param>
147             </xsl:call-template>
148         </xsl:if>
149         
150         <!-- Series -->
151         <xsl:if test="marc:datafield[@tag=440 or @tag=490]">
152         <span class="results_summary"><span class="label">Series: </span>
153         <!-- 440 -->
154         <xsl:for-each select="marc:datafield[@tag=440]">
155              <a href="/cgi-bin/koha/catalogue/search.pl?q=se:{marc:subfield[@code='a']}">
156             <xsl:call-template name="chopPunctuation">
157                             <xsl:with-param name="chopString">
158                                 <xsl:call-template name="subfieldSelect">
159                                     <xsl:with-param name="codes">av</xsl:with-param>
160                                 </xsl:call-template>
161                             </xsl:with-param>
162                         </xsl:call-template>
163                         </a>
164                     <xsl:text> </xsl:text><xsl:call-template name="part"/>
165             <xsl:choose><xsl:when test="position()=last()"><xsl:text>.</xsl:text></xsl:when><xsl:otherwise><xsl:text>; </xsl:text></xsl:otherwise></xsl:choose>
166         </xsl:for-each>
167
168         <!-- 490 Series not traced, Ind1 = 0 -->
169         <xsl:for-each select="marc:datafield[@tag=490][@ind1=0]">
170              <a href="/cgi-bin/koha/catalogue/search.pl?q=se:{marc:subfield[@code='a']}">
171                         <xsl:call-template name="chopPunctuation">
172                             <xsl:with-param name="chopString">
173                                 <xsl:call-template name="subfieldSelect">
174                                     <xsl:with-param name="codes">av</xsl:with-param>
175                                 </xsl:call-template>
176                             </xsl:with-param>
177                         </xsl:call-template>
178             </a>
179                     <xsl:call-template name="part"/>
180         <xsl:choose><xsl:when test="position()=last()"><xsl:text>.</xsl:text></xsl:when><xsl:otherwise><xsl:text>; </xsl:text></xsl:otherwise></xsl:choose>
181         </xsl:for-each>
182         <!-- 490 Series traced, Ind1 = 1 -->
183         <xsl:if test="marc:datafield[@tag=490][@ind1=1]">
184             <xsl:for-each select="marc:datafield[@tag=800 or @tag=810 or @tag=811 or @tag=830]">
185                 <xsl:choose>
186                     <xsl:when test="marc:subfield[@code='w']">
187                         <a href="/cgi-bin/koha/catalogue/search.pl?q=rcn:{marc:subfield[@code='w']}">
188                             <xsl:call-template name="chopPunctuation">
189                                 <xsl:with-param name="chopString">
190                                     <xsl:call-template name="subfieldSelect">
191                                         <xsl:with-param name="codes">at</xsl:with-param>
192                                     </xsl:call-template>
193                                 </xsl:with-param>
194                             </xsl:call-template>
195                         </a>
196                     </xsl:when>
197                     <xsl:otherwise>
198                         <a href="/cgi-bin/koha/catalogue/search.pl?q=se:{marc:subfield[@code='a']}">
199                             <xsl:call-template name="chopPunctuation">
200                                 <xsl:with-param name="chopString">
201                                     <xsl:call-template name="subfieldSelect">
202                                         <xsl:with-param name="codes">at</xsl:with-param>
203                                     </xsl:call-template>
204                                 </xsl:with-param>
205                             </xsl:call-template>
206                         </a>
207                         <xsl:call-template name="part"/>
208                     </xsl:otherwise>
209                 </xsl:choose>
210                 <xsl:text>: </xsl:text>
211                 <xsl:value-of  select="marc:subfield[@code='v']" />
212             <xsl:choose><xsl:when test="position()=last()"><xsl:text></xsl:text></xsl:when><xsl:otherwise><xsl:text>; </xsl:text></xsl:otherwise></xsl:choose>
213             </xsl:for-each>
214         </xsl:if>
215
216         </span>
217         </xsl:if>
218
219         <!-- Volumes of sets and traced series -->
220         <xsl:if test="$materialTypeCode='ST' or substring($controlField008,22,1)='m'">
221         <span class="results_summary"><span class="label">Volumes: </span>
222             <a>
223             <xsl:choose>
224             <xsl:when test="$UseControlNumber = '1' and marc:controlfield[@tag=001]">
225                 <xsl:attribute name="href">/cgi-bin/koha/catalogue/search.pl?q=rcn:<xsl:value-of select="marc:controlfield[@tag=001]"/></xsl:attribute>
226             </xsl:when>
227             <xsl:otherwise>
228                 <xsl:attribute name="href">/cgi-bin/koha/catalogue/search.pl?q=Title:<xsl:value-of select="translate(marc:datafield[@tag=245]/marc:subfield[@code='a'], '/', '')"/></xsl:attribute>
229             </xsl:otherwise>
230             </xsl:choose>
231             <xsl:text>Show volumes</xsl:text>
232             </a>
233         </span>
234         </xsl:if>
235
236         <!-- Set -->
237         <xsl:if test="$leader19='c'">
238         <span class="results_summary"><span class="label">Set: </span>
239         <xsl:for-each select="marc:datafield[@tag=773]">
240             <a>
241             <xsl:choose>
242             <xsl:when test="$UseControlNumber = '1' and marc:subfield[@code='w']">
243                 <xsl:attribute name="href">/cgi-bin/koha/catalogue/search.pl?q=Control-number:<xsl:value-of select="marc:subfield[@code='w']"/></xsl:attribute>
244             </xsl:when>
245             <xsl:otherwise>
246                 <xsl:attribute name="href">/cgi-bin/koha/catalogue/search.pl?q=Title:<xsl:value-of select="translate(//marc:datafield[@tag=245]/marc:subfield[@code='a'], '.', '')"/></xsl:attribute>
247             </xsl:otherwise>
248             </xsl:choose>
249             <xsl:value-of select="translate(//marc:datafield[@tag=245]/marc:subfield[@code='a'], '.', '')" />
250             </a>
251             <xsl:choose>
252                 <xsl:when test="position()=last()"></xsl:when>
253                 <xsl:otherwise><xsl:text>; </xsl:text></xsl:otherwise>
254             </xsl:choose>
255         </xsl:for-each>
256         </span>
257         </xsl:if>
258
259         <!-- Publisher Statement: Alternate Graphic Representation (MARC 880) -->
260         <xsl:if test="$display880">
261             <xsl:call-template name="m880Select">
262                 <xsl:with-param name="basetags">260</xsl:with-param>
263                 <xsl:with-param name="codes">abcg</xsl:with-param>
264                 <xsl:with-param name="class">results_summary</xsl:with-param>
265                 <xsl:with-param name="label">Publisher: </xsl:with-param>
266             </xsl:call-template>
267         </xsl:if>
268         
269         <xsl:if test="marc:datafield[@tag=260]">
270         <span class="results_summary"><span class="label">Publisher: </span>
271             <xsl:for-each select="marc:datafield[@tag=260]">
272                 <xsl:if test="marc:subfield[@code='b']">
273                 <a href="/cgi-bin/koha/catalogue/search.pl?q=pb:{marc:subfield[@code='b']}">
274                     <xsl:call-template name="subfieldSelect">
275                         <xsl:with-param name="codes">b</xsl:with-param>
276                     </xsl:call-template>
277                </a>
278                </xsl:if>
279                <xsl:text> </xsl:text>
280                 <xsl:call-template name="chopPunctuation">
281                   <xsl:with-param name="chopString">
282                     <xsl:call-template name="subfieldSelect">
283                         <xsl:with-param name="codes">acg</xsl:with-param>
284                     </xsl:call-template>
285                    </xsl:with-param>
286                </xsl:call-template>
287                     <xsl:choose><xsl:when test="position()=last()"><xsl:text>.</xsl:text></xsl:when><xsl:otherwise><xsl:text>; </xsl:text></xsl:otherwise></xsl:choose>
288             </xsl:for-each>
289         </span>
290         </xsl:if>
291
292         <!-- Edition Statement: Alternate Graphic Representation (MARC 880) -->
293         <xsl:if test="$display880">
294             <xsl:call-template name="m880Select">
295                 <xsl:with-param name="basetags">250</xsl:with-param>
296                 <xsl:with-param name="codes">ab</xsl:with-param>
297                 <xsl:with-param name="class">results_summary</xsl:with-param>
298                 <xsl:with-param name="label">Edition: </xsl:with-param>
299             </xsl:call-template>
300         </xsl:if>
301         
302         <xsl:if test="marc:datafield[@tag=250]">
303         <span class="results_summary"><span class="label">Edition: </span>
304             <xsl:for-each select="marc:datafield[@tag=250]">
305                 <xsl:call-template name="chopPunctuation">
306                   <xsl:with-param name="chopString">
307                     <xsl:call-template name="subfieldSelect">
308                         <xsl:with-param name="codes">ab</xsl:with-param>
309                     </xsl:call-template>
310                    </xsl:with-param>
311                </xsl:call-template>
312                     <xsl:choose><xsl:when test="position()=last()"><xsl:text>.</xsl:text></xsl:when><xsl:otherwise><xsl:text>; </xsl:text></xsl:otherwise></xsl:choose>
313             </xsl:for-each>
314         </span>
315         </xsl:if>
316
317         <!-- Description: Alternate Graphic Representation (MARC 880) -->
318         <xsl:if test="$display880">
319             <xsl:call-template name="m880Select">
320                 <xsl:with-param name="basetags">300</xsl:with-param>
321                 <xsl:with-param name="codes">abceg</xsl:with-param>
322                 <xsl:with-param name="class">results_summary</xsl:with-param>
323                 <xsl:with-param name="label">Description: </xsl:with-param>
324             </xsl:call-template>
325         </xsl:if>
326         
327         <xsl:if test="marc:datafield[@tag=300]">
328         <span class="results_summary"><span class="label">Description: </span>
329             <xsl:for-each select="marc:datafield[@tag=300]">
330                 <xsl:call-template name="chopPunctuation">
331                   <xsl:with-param name="chopString">
332                     <xsl:call-template name="subfieldSelect">
333                         <xsl:with-param name="codes">abceg</xsl:with-param>
334                     </xsl:call-template>
335                    </xsl:with-param>
336                </xsl:call-template>
337                     <xsl:choose><xsl:when test="position()=last()"><xsl:text>.</xsl:text></xsl:when><xsl:otherwise><xsl:text>; </xsl:text></xsl:otherwise></xsl:choose>
338             </xsl:for-each>
339         </span>
340        </xsl:if>
341
342        <xsl:if test="marc:datafield[@tag=020]">
343         <span class="results_summary"><span class="label">ISBN: </span>
344         <xsl:for-each select="marc:datafield[@tag=020]">
345         <xsl:variable name="isbn" select="marc:subfield[@code='a']"/>
346                 <xsl:value-of select="marc:subfield[@code='a']"/>
347                 <xsl:choose><xsl:when test="position()=last()"><xsl:text>.</xsl:text></xsl:when><xsl:otherwise><xsl:text>; </xsl:text></xsl:otherwise></xsl:choose>
348         </xsl:for-each>
349         </span>
350         </xsl:if>
351
352         <xsl:if test="marc:datafield[@tag=022]">
353         <span class="results_summary"><span class="label">ISSN: </span>
354         <xsl:for-each select="marc:datafield[@tag=022]">
355                 <xsl:value-of select="marc:subfield[@code='a']"/>
356                 <xsl:choose><xsl:when test="position()=last()"><xsl:text>.</xsl:text></xsl:when><xsl:otherwise><xsl:text>; </xsl:text></xsl:otherwise></xsl:choose>
357         </xsl:for-each>
358         </span>
359         </xsl:if>
360
361         <!-- Other Title  Statement: Alternate Graphic Representation (MARC 880) -->
362         <xsl:if test="$display880">
363             <xsl:call-template name="m880Select">
364                 <xsl:with-param name="basetags">246</xsl:with-param>
365                 <xsl:with-param name="codes">abhfgnp</xsl:with-param>
366                 <xsl:with-param name="class">results_summary</xsl:with-param>
367                 <xsl:with-param name="label">Other Title: </xsl:with-param>
368             </xsl:call-template>
369         </xsl:if>
370
371         <xsl:if test="marc:datafield[@tag=246]">
372         <span class="results_summary"><span class="label">Other Title: </span>
373             <xsl:for-each select="marc:datafield[@tag=246]">
374                 <xsl:call-template name="chopPunctuation">
375                   <xsl:with-param name="chopString">
376                     <xsl:call-template name="subfieldSelect">
377                         <xsl:with-param name="codes">iabhfgnp</xsl:with-param>
378                     </xsl:call-template>
379                    </xsl:with-param>
380                </xsl:call-template>
381                     <xsl:choose><xsl:when test="position()=last()"><xsl:text>.</xsl:text></xsl:when><xsl:otherwise><xsl:text>; </xsl:text></xsl:otherwise></xsl:choose>
382             </xsl:for-each>
383         </span>
384        </xsl:if>
385
386         <!-- Uniform Title  Statement: Alternate Graphic Representation (MARC 880) -->
387         <xsl:if test="$display880">
388             <xsl:call-template name="m880Select">
389                 <xsl:with-param name="basetags">130,240</xsl:with-param>
390                 <xsl:with-param name="codes">adfklmor</xsl:with-param>
391                 <xsl:with-param name="class">results_summary</xsl:with-param>
392                 <xsl:with-param name="label">Uniform Title: </xsl:with-param>
393             </xsl:call-template>
394         </xsl:if>
395
396         <xsl:if test="marc:datafield[@tag=130]|marc:datafield[@tag=240]|marc:datafield[@tag=730][@ind2!=2]">
397         <span class="results_summary"><span class="label">Uniform titles: </span>
398         <xsl:for-each select="marc:datafield[@tag=130]|marc:datafield[@tag=240]|marc:datafield[@tag=730][@ind2!=2]">
399             <xsl:variable name="str">
400                 <xsl:for-each select="marc:subfield">
401                     <xsl:if test="(contains('adfklmor',@code) and (not(../marc:subfield[@code='n' or @code='p']) or (following-sibling::marc:subfield[@code='n' or @code='p'])))">
402                         <xsl:value-of select="text()"/>
403                         <xsl:text> </xsl:text>
404                      </xsl:if>
405                 </xsl:for-each>
406             </xsl:variable>
407             <xsl:call-template name="chopPunctuation">
408                 <xsl:with-param name="chopString">
409                     <xsl:value-of select="substring($str,1,string-length($str)-1)"/>
410                         
411                 </xsl:with-param>
412             </xsl:call-template>
413             <xsl:choose><xsl:when test="position()=last()"><xsl:text>.</xsl:text></xsl:when><xsl:otherwise><xsl:text>; </xsl:text></xsl:otherwise></xsl:choose>
414         </xsl:for-each>
415         </span>
416         </xsl:if>
417
418         <xsl:if test="marc:datafield[substring(@tag, 1, 1) = '6']">
419             <span class="results_summary"><span class="label">Subject(s): </span>
420             <xsl:for-each select="marc:datafield[substring(@tag, 1, 1) = '6']">
421             <a>
422             <xsl:choose>
423             <xsl:when test="marc:subfield[@code=9] and $UseAuthoritiesForTracings='1'">
424                 <xsl:attribute name="href">/cgi-bin/koha/catalogue/search.pl?q=an:<xsl:value-of select="marc:subfield[@code=9]"/></xsl:attribute>
425             </xsl:when>
426             <xsl:when test="$TraceSubjectSubdivisions='1'">
427                 <xsl:attribute name="href">/cgi-bin/koha/catalogue/search.pl?q=<xsl:call-template name="subfieldSelect">
428                         <xsl:with-param name="codes">abcdfgklmnopqrstvxyz</xsl:with-param>
429                         <xsl:with-param name="delimeter"> and </xsl:with-param>
430                         <xsl:with-param name="prefix">(su<xsl:value-of select="$SubjectModifier"/>:"</xsl:with-param>
431                         <xsl:with-param name="suffix">")</xsl:with-param>
432                     </xsl:call-template>
433                 </xsl:attribute>
434             </xsl:when>
435             <xsl:otherwise>
436                 <xsl:attribute name="href">/cgi-bin/koha/catalogue/search.pl?q=su<xsl:value-of select="$SubjectModifier"/>:"<xsl:value-of select="marc:subfield[@code='a']"/>"</xsl:attribute>
437             </xsl:otherwise>
438             </xsl:choose>
439             <xsl:call-template name="chopPunctuation">
440                 <xsl:with-param name="chopString">
441                     <xsl:call-template name="subfieldSelect">
442                         <xsl:with-param name="codes">abcdfgklmnopqrstvxyz</xsl:with-param>
443                         <xsl:with-param name="subdivCodes">vxyz</xsl:with-param>
444                         <xsl:with-param name="subdivDelimiter">-- </xsl:with-param>
445                     </xsl:call-template>
446                 </xsl:with-param>
447             </xsl:call-template>
448             </a>
449             <xsl:choose>
450             <xsl:when test="position()=last()"></xsl:when>
451             <xsl:otherwise> | </xsl:otherwise>
452             </xsl:choose>
453
454             </xsl:for-each>
455             </span>
456         </xsl:if>
457
458         <xsl:if test="marc:datafield[@tag=856]">
459         <span class="results_summary"><span class="label">Online Resources: </span>
460         <xsl:for-each select="marc:datafield[@tag=856]">
461                                    <xsl:variable name="SubqText"><xsl:value-of select="marc:subfield[@code='q']"/></xsl:variable>
462                                    <a><xsl:attribute name="href"><xsl:value-of select="marc:subfield[@code='u']"/></xsl:attribute>
463                                     <xsl:choose>
464                                     <xsl:when test="($Show856uAsImage='Details' or $Show856uAsImage='Both') and (substring($SubqText,1,6)='image/' or $SubqText='img' or $SubqText='bmp' or $SubqText='cod' or $SubqText='gif' or $SubqText='ief' or $SubqText='jpe' or $SubqText='jpeg' or $SubqText='jpg' or $SubqText='jfif' or $SubqText='png' or $SubqText='svg' or $SubqText='tif' or $SubqText='tiff' or $SubqText='ras' or $SubqText='cmx' or $SubqText='ico' or $SubqText='pnm' or $SubqText='pbm' or $SubqText='pgm' or $SubqText='ppm' or $SubqText='rgb' or $SubqText='xbm' or $SubqText='xpm' or $SubqText='xwd')">
465                                         <xsl:element name="img"><xsl:attribute name="src"><xsl:value-of select="marc:subfield[@code='u']"/></xsl:attribute><xsl:attribute name="alt"><xsl:value-of select="marc:subfield[@code='y']"/></xsl:attribute><xsl:attribute name="height">100</xsl:attribute></xsl:element><xsl:text></xsl:text>
466                                     </xsl:when>
467                                     <xsl:when test="marc:subfield[@code='y' or @code='3' or @code='z']">
468                                         <xsl:call-template name="subfieldSelect">
469                                         <xsl:with-param name="codes">y3z</xsl:with-param>
470                                         </xsl:call-template>
471                                     </xsl:when>
472                                     <xsl:when test="not(marc:subfield[@code='y']) and not(marc:subfield[@code='3']) and not(marc:subfield[@code='z'])">
473                                         <xsl:choose>
474                                         <xsl:when test="$URLLinkText!=''">
475                                                 <xsl:value-of select="$URLLinkText"/>
476                                         </xsl:when>
477                                         <xsl:otherwise>
478                                                 <xsl:text>Click here to access online</xsl:text>
479                                         </xsl:otherwise>
480                                         </xsl:choose>
481                                     </xsl:when>
482                                     </xsl:choose>
483                                     </a>
484                                     <xsl:choose>
485                                     <xsl:when test="position()=last()"><xsl:text>  </xsl:text></xsl:when>
486                                     <xsl:otherwise> | </xsl:otherwise>
487                                     </xsl:choose>
488
489         </xsl:for-each>
490         </span>
491         </xsl:if>
492         <xsl:if test="marc:datafield[@tag=505]">
493         <xsl:for-each select="marc:datafield[@tag=505]">
494         <span class="results_summary">
495         <xsl:choose>
496         <xsl:when test="@ind1=0">
497             <span class="label">Contents:</span>
498         </xsl:when>
499         <xsl:when test="@ind1=1">
500             <span class="label">Incomplete contents:</span>
501         </xsl:when>
502         <xsl:when test="@ind1=1">
503             <span class="label">Partial contents:</span>
504         </xsl:when>
505         </xsl:choose>  
506         <xsl:choose>
507         <xsl:when test="@ind2=0">
508             <xsl:call-template name="subfieldSelect">
509                 <xsl:with-param name="codes">tru</xsl:with-param>
510             </xsl:call-template>
511         </xsl:when>
512         <xsl:otherwise>
513             <xsl:call-template name="subfieldSelect">
514                 <xsl:with-param name="codes">au</xsl:with-param>
515             </xsl:call-template>
516         </xsl:otherwise>
517         </xsl:choose>
518         </span>
519         </xsl:for-each>
520         </xsl:if>
521
522         <!-- 773 -->
523         <xsl:if test="marc:datafield[@tag=773]">
524         <xsl:for-each select="marc:datafield[@tag=773]">
525         <xsl:if test="@ind1=0">
526         <span class="results_summary"><span class="label">
527         <xsl:choose>
528         <xsl:when test="@ind2=' '">
529             In:
530         </xsl:when>
531         <xsl:when test="@ind2=8">
532             <xsl:if test="marc:subfield[@code='i']">
533                 <xsl:value-of select="marc:subfield[@code='i']"/>
534             </xsl:if>
535         </xsl:when>
536         </xsl:choose>
537         </span>
538                 <xsl:variable name="f773">
539                     <xsl:call-template name="chopPunctuation"><xsl:with-param name="chopString"><xsl:call-template name="subfieldSelect">
540                         <xsl:with-param name="codes">at</xsl:with-param>
541                     </xsl:call-template></xsl:with-param></xsl:call-template>
542                 </xsl:variable>
543             <xsl:choose>
544                 <xsl:when test="$UseControlNumber = '1' and marc:subfield[@code='w']">
545                     <a><xsl:attribute name="href">/cgi-bin/koha/catalogue/search.pl?q=Control-number:<xsl:call-template name="extractControlNumber"><xsl:with-param name="subfieldW" select="marc:subfield[@code='w']"/></xsl:call-template></xsl:attribute>
546                         <xsl:value-of select="translate($f773, '()', '')"/><xsl:if test="marc:subfield[@code='g']"><xsl:text> </xsl:text><xsl:value-of select="marc:subfield[@code='g']"/></xsl:if>
547                     </a>
548                 </xsl:when>
549                 <xsl:otherwise>
550                     <a><xsl:attribute name="href">/cgi-bin/koha/catalogue/search.pl?q=Title:<xsl:value-of select="translate($f773, '()', '')"/></xsl:attribute>
551                         <xsl:value-of select="$f773"/><xsl:if test="marc:subfield[@code='g']"><xsl:text> </xsl:text><xsl:value-of select="marc:subfield[@code='g']"/></xsl:if>
552                     </a>
553                 </xsl:otherwise>
554             </xsl:choose>
555         </span>
556
557         <xsl:if test="marc:subfield[@code='n']">
558             <span class="results_summary"><xsl:value-of select="marc:subfield[@code='n']"/></span>
559         </xsl:if>
560
561         </xsl:if>
562         </xsl:for-each>
563         </xsl:if>
564
565         <!--  775 Other Edition  -->
566         <xsl:if test="marc:datafield[@tag=775]">
567         <span class="results_summary"><span class="label">Other Editions: </span>
568         <xsl:for-each select="marc:datafield[@tag=775]">
569             <xsl:if test="marc:subfield[@code='i']">
570                 <xsl:call-template name="subfieldSelect">
571                     <xsl:with-param name="codes">i</xsl:with-param>
572                 </xsl:call-template>
573                 <xsl:text>: </xsl:text>
574             </xsl:if>
575             <a>
576             <xsl:choose>
577             <xsl:when test="$UseControlNumber = '1' and marc:subfield[@code='w']">
578                 <xsl:attribute name="href">/cgi-bin/koha/catalogue/search.pl?q=Control-number:<xsl:value-of select="marc:subfield[@code='w']"/></xsl:attribute>
579             </xsl:when>
580             <xsl:otherwise>
581                 <xsl:attribute name="href">/cgi-bin/koha/catalogue/search.pl?q=Title:<xsl:value-of select="translate(marc:subfield[@code='t'], '.', '')"/></xsl:attribute>
582             </xsl:otherwise>
583             </xsl:choose>
584             <xsl:call-template name="subfieldSelect">
585                 <xsl:with-param name="codes">t</xsl:with-param>
586             </xsl:call-template>
587             </a>
588             <xsl:choose>
589                 <xsl:when test="position()=last()"></xsl:when>
590                 <xsl:otherwise><xsl:text>; </xsl:text></xsl:otherwise>
591             </xsl:choose>
592         </xsl:for-each>
593         </span>
594         </xsl:if>
595
596         <!-- 780 -->
597         <xsl:if test="marc:datafield[@tag=780]">
598         <xsl:for-each select="marc:datafield[@tag=780]">
599         <xsl:if test="@ind1=0">
600         <span class="results_summary">
601         <xsl:choose>
602         <xsl:when test="@ind2=0">
603             <span class="label">Continues:</span>
604         </xsl:when>
605         <xsl:when test="@ind2=1">
606             <span class="label">Continues in part:</span>
607         </xsl:when>
608         <xsl:when test="@ind2=2">
609             <span class="label">Supersedes:</span>
610         </xsl:when>
611         <xsl:when test="@ind2=3">
612             <span class="label">Supersedes in part:</span>
613         </xsl:when>
614         <xsl:when test="@ind2=4">
615             <span class="label">Formed by the union: ... and: ...</span>
616         </xsl:when>
617         <xsl:when test="@ind2=5">
618             <span class="label">Absorbed:</span>
619         </xsl:when>
620         <xsl:when test="@ind2=6">
621             <span class="label">Absorbed in part:</span>
622         </xsl:when>
623         <xsl:when test="@ind2=7">
624             <span class="label">Separated from:</span>
625         </xsl:when>
626         </xsl:choose>
627                 <xsl:variable name="f780">
628                     <xsl:call-template name="subfieldSelect">
629                         <xsl:with-param name="codes">at</xsl:with-param>
630                     </xsl:call-template>
631                 </xsl:variable>
632             <xsl:choose>
633                 <xsl:when test="$UseControlNumber = '1' and marc:subfield[@code='w']">
634                     <a href="/cgi-bin/koha/catalogue/search.pl?q=Control-number:{marc:subfield[@code='w']}">
635                         <xsl:value-of select="translate($f780, '()', '')"/>
636                     </a>
637                 </xsl:when>
638                 <xsl:otherwise>
639                     <a><xsl:attribute name="href">/cgi-bin/koha/catalogue/search.pl?q=<xsl:value-of select="translate($f780, '()', '')"/></xsl:attribute>
640                         <xsl:value-of select="translate($f780, '()', '')"/>
641                     </a>
642                 </xsl:otherwise>
643             </xsl:choose>
644         </span>
645  
646         <xsl:if test="marc:subfield[@code='n']">
647             <span class="results_summary"><xsl:value-of select="marc:subfield[@code='n']"/></span>
648         </xsl:if>
649
650         </xsl:if>
651         </xsl:for-each>
652         </xsl:if>
653
654         <!-- 785 -->
655         <xsl:if test="marc:datafield[@tag=785]">
656         <xsl:for-each select="marc:datafield[@tag=785]">
657         <span class="results_summary">
658         <xsl:choose>
659         <xsl:when test="@ind2=0">
660             <span class="label">Continued by:</span>
661         </xsl:when>
662         <xsl:when test="@ind2=1">
663             <span class="label">Continued in part by:</span>
664         </xsl:when>
665         <xsl:when test="@ind2=2">
666             <span class="label">Superseded by:</span>
667         </xsl:when>
668         <xsl:when test="@ind2=3">
669             <span class="label">Superseded in part by:</span>
670         </xsl:when>
671         <xsl:when test="@ind2=4">
672             <span class="label">Absorbed by:</span>
673         </xsl:when>
674         <xsl:when test="@ind2=5">
675             <span class="label">Absorbed in part by:</span>
676         </xsl:when>
677         <xsl:when test="@ind2=6">
678             <span class="label">Split into .. and ...:</span>
679         </xsl:when>
680         <xsl:when test="@ind2=7">
681             <span class="label">Merged with ... to form ...</span>
682         </xsl:when>
683         <xsl:when test="@ind2=8">
684             <span class="label">Changed back to:</span>
685         </xsl:when>
686
687         </xsl:choose>
688                    <xsl:variable name="f785">
689                     <xsl:call-template name="subfieldSelect">
690                         <xsl:with-param name="codes">at</xsl:with-param>
691                     </xsl:call-template>
692                 </xsl:variable>
693
694             <xsl:choose>
695                 <xsl:when test="$UseControlNumber = '1' and marc:subfield[@code='w']">
696                     <a href="/cgi-bin/koha/catalogue/search.pl?q=Control-number:{marc:subfield[@code='w']}">
697                         <xsl:value-of select="translate($f785, '()', '')"/>
698                     </a>
699                 </xsl:when>
700                 <xsl:otherwise>
701                     <a><xsl:attribute name="href">/cgi-bin/koha/catalogue/search.pl?q=<xsl:value-of select="translate($f785, '()', '')"/></xsl:attribute>
702                         <xsl:value-of select="translate($f785, '()', '')"/>
703                     </a>
704                 </xsl:otherwise>
705             </xsl:choose>
706
707         </span>
708         </xsl:for-each>
709         </xsl:if>
710
711         <xsl:if test="$OPACBaseURL!=''">
712         <span class="results_summary"><span class="label">OPAC view: </span>
713             <a><xsl:attribute name="href">http://<xsl:value-of select="$OPACBaseURL"/>/cgi-bin/koha/opac-detail.pl?biblionumber=<xsl:value-of select="marc:datafield[@tag=999]/marc:subfield[@code='c']"/></xsl:attribute><xsl:attribute name="target">_blank</xsl:attribute>Open in new window</a>.
714         </span>
715         </xsl:if>
716
717     </xsl:template>
718
719     <xsl:template name="nameABCDQ">
720             <xsl:call-template name="chopPunctuation">
721                 <xsl:with-param name="chopString">
722                     <xsl:call-template name="subfieldSelect">
723                         <xsl:with-param name="codes">aq</xsl:with-param>
724                     </xsl:call-template>
725                 </xsl:with-param>
726                 <xsl:with-param name="punctuation">
727                     <xsl:text>:,;/ </xsl:text>
728                 </xsl:with-param>
729             </xsl:call-template>
730         <xsl:call-template name="termsOfAddress"/>
731     </xsl:template>
732
733     <xsl:template name="nameABCDN">
734         <xsl:for-each select="marc:subfield[@code='a']">
735                 <xsl:call-template name="chopPunctuation">
736                     <xsl:with-param name="chopString" select="."/>
737                 </xsl:call-template>
738         </xsl:for-each>
739         <xsl:for-each select="marc:subfield[@code='b']">
740                 <xsl:value-of select="."/>
741         </xsl:for-each>
742         <xsl:if test="marc:subfield[@code='c'] or marc:subfield[@code='d'] or marc:subfield[@code='n']">
743                 <xsl:call-template name="subfieldSelect">
744                     <xsl:with-param name="codes">cdn</xsl:with-param>
745                 </xsl:call-template>
746         </xsl:if>
747     </xsl:template>
748
749     <xsl:template name="nameACDEQ">
750             <xsl:call-template name="subfieldSelect">
751                 <xsl:with-param name="codes">acdeq</xsl:with-param>
752             </xsl:call-template>
753     </xsl:template>
754     <xsl:template name="termsOfAddress">
755         <xsl:if test="marc:subfield[@code='b' or @code='c']">
756             <xsl:call-template name="chopPunctuation">
757                 <xsl:with-param name="chopString">
758                     <xsl:call-template name="subfieldSelect">
759                         <xsl:with-param name="codes">bc</xsl:with-param>
760                     </xsl:call-template>
761                 </xsl:with-param>
762             </xsl:call-template>
763         </xsl:if>
764     </xsl:template>
765
766     <xsl:template name="part">
767         <xsl:variable name="partNumber">
768             <xsl:call-template name="specialSubfieldSelect">
769                 <xsl:with-param name="axis">n</xsl:with-param>
770                 <xsl:with-param name="anyCodes">n</xsl:with-param>
771                 <xsl:with-param name="afterCodes">fghkdlmor</xsl:with-param>
772             </xsl:call-template>
773         </xsl:variable>
774         <xsl:variable name="partName">
775             <xsl:call-template name="specialSubfieldSelect">
776                 <xsl:with-param name="axis">p</xsl:with-param>
777                 <xsl:with-param name="anyCodes">p</xsl:with-param>
778                 <xsl:with-param name="afterCodes">fghkdlmor</xsl:with-param>
779             </xsl:call-template>
780         </xsl:variable>
781         <xsl:if test="string-length(normalize-space($partNumber))">
782                 <xsl:call-template name="chopPunctuation">
783                     <xsl:with-param name="chopString" select="$partNumber"/>
784                 </xsl:call-template>
785         </xsl:if>
786         <xsl:if test="string-length(normalize-space($partName))">
787                 <xsl:call-template name="chopPunctuation">
788                     <xsl:with-param name="chopString" select="$partName"/>
789                 </xsl:call-template>
790         </xsl:if>
791     </xsl:template>
792
793     <xsl:template name="specialSubfieldSelect">
794         <xsl:param name="anyCodes"/>
795         <xsl:param name="axis"/>
796         <xsl:param name="beforeCodes"/>
797         <xsl:param name="afterCodes"/>
798         <xsl:variable name="str">
799             <xsl:for-each select="marc:subfield">
800                 <xsl:if test="contains($anyCodes, @code)      or (contains($beforeCodes,@code) and following-sibling::marc:subfield[@code=$axis])      or (contains($afterCodes,@code) and preceding-sibling::marc:subfield[@code=$axis])">
801                     <xsl:value-of select="text()"/>
802                     <xsl:text> </xsl:text>
803                 </xsl:if>
804             </xsl:for-each>
805         </xsl:variable>
806         <xsl:value-of select="substring($str,1,string-length($str)-1)"/>
807     </xsl:template>
808
809     <xsl:template name="showAuthor">
810         <xsl:param name="authorfield"/>
811     <xsl:param name="UseAuthoritiesForTracings"/>
812         <xsl:if test="count($authorfield)&gt;0">
813         <h5 class="author">
814         <xsl:for-each select="$authorfield">
815         <xsl:choose>
816           <xsl:when test="position()&gt;1"/>
817           <xsl:when test="@tag&lt;700">Author(s): </xsl:when>
818           <xsl:otherwise>Additional author(s): </xsl:otherwise>
819         </xsl:choose>
820         <a>
821         <xsl:choose>
822             <xsl:when test="marc:subfield[@code=9] and $UseAuthoritiesForTracings='1'">
823                 <xsl:attribute name="href">/cgi-bin/koha/catalogue/search.pl?q=an:<xsl:value-of select="marc:subfield[@code=9]"/></xsl:attribute>
824             </xsl:when>
825             <xsl:otherwise>
826             <xsl:attribute name="href">/cgi-bin/koha/catalogue/search.pl?q=au:<xsl:value-of select="marc:subfield[@code='a']"/></xsl:attribute>
827             </xsl:otherwise>
828         </xsl:choose>
829         <xsl:choose>
830           <xsl:when test="@tag=100 or @tag=700"><xsl:call-template name="nameABCDQ"/></xsl:when>
831           <xsl:when test="@tag=110 or @tag=710"><xsl:call-template name="nameABCDN"/></xsl:when>
832           <xsl:when test="@tag=111 or @tag=711"><xsl:call-template name="nameACDEQ"/></xsl:when>
833         </xsl:choose>
834         <!-- add relator code too between brackets-->
835         <xsl:if test="marc:subfield[@code='4' or @code='e']">
836           <xsl:text>[</xsl:text>
837           <xsl:choose>
838             <xsl:when test="marc:subfield[@code=4]"><xsl:value-of select="marc:subfield[@code=4]"/></xsl:when>
839             <xsl:otherwise><xsl:value-of select="marc:subfield[@code='e']"/></xsl:otherwise>
840           </xsl:choose>
841           <xsl:text>]</xsl:text>
842         </xsl:if>
843         </a>
844         <xsl:choose>
845           <xsl:when test="position()=last()"><xsl:text>.</xsl:text></xsl:when><xsl:otherwise><xsl:text>; </xsl:text></xsl:otherwise>
846         </xsl:choose>
847         </xsl:for-each>
848         </h5>
849         </xsl:if>
850     </xsl:template>
851
852 </xsl:stylesheet>