Bug 4506: Add link to volumes of traced series to series record
[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
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              <a><xsl:attribute name="href">/cgi-bin/koha/catalogue/search.pl?q=<xsl:value-of select="translate($f780, '()', '')"/></xsl:attribute>
651                 <xsl:value-of select="translate($f780, '()', '')"/>
652             </a>
653         </span>
654  
655         <xsl:choose>
656         <xsl:when test="@ind1=0">
657             <span class="results_summary"><xsl:value-of select="marc:subfield[@code='n']"/></span>
658         </xsl:when>
659         </xsl:choose>
660
661         </xsl:for-each>
662         </xsl:if>
663
664         <!-- 785 -->
665         <xsl:if test="marc:datafield[@tag=785]">
666         <xsl:for-each select="marc:datafield[@tag=785]">
667         <span class="results_summary">
668         <xsl:choose>
669         <xsl:when test="@ind2=0">
670             <span class="label">Continued by:</span>
671         </xsl:when>
672         <xsl:when test="@ind2=1">
673             <span class="label">Continued in part by:</span>
674         </xsl:when>
675         <xsl:when test="@ind2=2">
676             <span class="label">Superseded by:</span>
677         </xsl:when>
678         <xsl:when test="@ind2=3">
679             <span class="label">Superseded in part by:</span>
680         </xsl:when>
681         <xsl:when test="@ind2=4">
682             <span class="label">Absorbed by:</span>
683         </xsl:when>
684         <xsl:when test="@ind2=5">
685             <span class="label">Absorbed in part by:</span>
686         </xsl:when>
687         <xsl:when test="@ind2=6">
688             <span class="label">Split into .. and ...:</span>
689         </xsl:when>
690         <xsl:when test="@ind2=7">
691             <span class="label">Merged with ... to form ...</span>
692         </xsl:when>
693         <xsl:when test="@ind2=8">
694             <span class="label">Changed back to:</span>
695         </xsl:when>
696
697         </xsl:choose>
698                    <xsl:variable name="f785">
699                     <xsl:call-template name="subfieldSelect">
700                         <xsl:with-param name="codes">at</xsl:with-param>
701                     </xsl:call-template>
702                 </xsl:variable>
703
704                 <a><xsl:attribute name="href">/cgi-bin/koha/catalogue/search.pl?q=<xsl:value-of select="translate($f785, '()', '')"/></xsl:attribute>
705                 <xsl:value-of select="translate($f785, '()', '')"/>
706             </a>
707
708         </span>
709         </xsl:for-each>
710         </xsl:if>
711
712         <xsl:if test="$OPACBaseURL!=''">
713         <span class="results_summary"><span class="label">OPAC view: </span>
714             <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>.
715         </span>
716         </xsl:if>
717
718     </xsl:template>
719
720     <xsl:template name="nameABCDQ">
721             <xsl:call-template name="chopPunctuation">
722                 <xsl:with-param name="chopString">
723                     <xsl:call-template name="subfieldSelect">
724                         <xsl:with-param name="codes">aq</xsl:with-param>
725                     </xsl:call-template>
726                 </xsl:with-param>
727                 <xsl:with-param name="punctuation">
728                     <xsl:text>:,;/ </xsl:text>
729                 </xsl:with-param>
730             </xsl:call-template>
731         <xsl:call-template name="termsOfAddress"/>
732     </xsl:template>
733
734     <xsl:template name="nameABCDN">
735         <xsl:for-each select="marc:subfield[@code='a']">
736                 <xsl:call-template name="chopPunctuation">
737                     <xsl:with-param name="chopString" select="."/>
738                 </xsl:call-template>
739         </xsl:for-each>
740         <xsl:for-each select="marc:subfield[@code='b']">
741                 <xsl:value-of select="."/>
742         </xsl:for-each>
743         <xsl:if test="marc:subfield[@code='c'] or marc:subfield[@code='d'] or marc:subfield[@code='n']">
744                 <xsl:call-template name="subfieldSelect">
745                     <xsl:with-param name="codes">cdn</xsl:with-param>
746                 </xsl:call-template>
747         </xsl:if>
748     </xsl:template>
749
750     <xsl:template name="nameACDEQ">
751             <xsl:call-template name="subfieldSelect">
752                 <xsl:with-param name="codes">acdeq</xsl:with-param>
753             </xsl:call-template>
754     </xsl:template>
755     <xsl:template name="termsOfAddress">
756         <xsl:if test="marc:subfield[@code='b' or @code='c']">
757             <xsl:call-template name="chopPunctuation">
758                 <xsl:with-param name="chopString">
759                     <xsl:call-template name="subfieldSelect">
760                         <xsl:with-param name="codes">bc</xsl:with-param>
761                     </xsl:call-template>
762                 </xsl:with-param>
763             </xsl:call-template>
764         </xsl:if>
765     </xsl:template>
766
767     <xsl:template name="part">
768         <xsl:variable name="partNumber">
769             <xsl:call-template name="specialSubfieldSelect">
770                 <xsl:with-param name="axis">n</xsl:with-param>
771                 <xsl:with-param name="anyCodes">n</xsl:with-param>
772                 <xsl:with-param name="afterCodes">fghkdlmor</xsl:with-param>
773             </xsl:call-template>
774         </xsl:variable>
775         <xsl:variable name="partName">
776             <xsl:call-template name="specialSubfieldSelect">
777                 <xsl:with-param name="axis">p</xsl:with-param>
778                 <xsl:with-param name="anyCodes">p</xsl:with-param>
779                 <xsl:with-param name="afterCodes">fghkdlmor</xsl:with-param>
780             </xsl:call-template>
781         </xsl:variable>
782         <xsl:if test="string-length(normalize-space($partNumber))">
783                 <xsl:call-template name="chopPunctuation">
784                     <xsl:with-param name="chopString" select="$partNumber"/>
785                 </xsl:call-template>
786         </xsl:if>
787         <xsl:if test="string-length(normalize-space($partName))">
788                 <xsl:call-template name="chopPunctuation">
789                     <xsl:with-param name="chopString" select="$partName"/>
790                 </xsl:call-template>
791         </xsl:if>
792     </xsl:template>
793
794     <xsl:template name="specialSubfieldSelect">
795         <xsl:param name="anyCodes"/>
796         <xsl:param name="axis"/>
797         <xsl:param name="beforeCodes"/>
798         <xsl:param name="afterCodes"/>
799         <xsl:variable name="str">
800             <xsl:for-each select="marc:subfield">
801                 <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])">
802                     <xsl:value-of select="text()"/>
803                     <xsl:text> </xsl:text>
804                 </xsl:if>
805             </xsl:for-each>
806         </xsl:variable>
807         <xsl:value-of select="substring($str,1,string-length($str)-1)"/>
808     </xsl:template>
809
810 </xsl:stylesheet>