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