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