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