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