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