Bug 4506: Add set > volume link
[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'">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         <!-- Publisher Statement: Alternate Graphic Representation (MARC 880) -->
236         <xsl:if test="$display880">
237             <xsl:call-template name="m880Select">
238                 <xsl:with-param name="basetags">260</xsl:with-param>
239                 <xsl:with-param name="codes">abcg</xsl:with-param>
240                 <xsl:with-param name="class">results_summary</xsl:with-param>
241                 <xsl:with-param name="label">Publisher: </xsl:with-param>
242             </xsl:call-template>
243         </xsl:if>
244         
245         <xsl:if test="marc:datafield[@tag=260]">
246         <span class="results_summary"><span class="label">Publisher: </span>
247             <xsl:for-each select="marc:datafield[@tag=260]">
248                 <xsl:if test="marc:subfield[@code='b']">
249                 <a href="/cgi-bin/koha/catalogue/search.pl?q=pb:{marc:subfield[@code='b']}">
250                     <xsl:call-template name="subfieldSelect">
251                         <xsl:with-param name="codes">b</xsl:with-param>
252                     </xsl:call-template>
253                </a>
254                </xsl:if>
255                <xsl:text> </xsl:text>
256                 <xsl:call-template name="chopPunctuation">
257                   <xsl:with-param name="chopString">
258                     <xsl:call-template name="subfieldSelect">
259                         <xsl:with-param name="codes">acg</xsl:with-param>
260                     </xsl:call-template>
261                    </xsl:with-param>
262                </xsl:call-template>
263                     <xsl:choose><xsl:when test="position()=last()"><xsl:text>.</xsl:text></xsl:when><xsl:otherwise><xsl:text>; </xsl:text></xsl:otherwise></xsl:choose>
264             </xsl:for-each>
265         </span>
266         </xsl:if>
267
268         <!-- Edition Statement: Alternate Graphic Representation (MARC 880) -->
269         <xsl:if test="$display880">
270             <xsl:call-template name="m880Select">
271                 <xsl:with-param name="basetags">250</xsl:with-param>
272                 <xsl:with-param name="codes">ab</xsl:with-param>
273                 <xsl:with-param name="class">results_summary</xsl:with-param>
274                 <xsl:with-param name="label">Edition: </xsl:with-param>
275             </xsl:call-template>
276         </xsl:if>
277         
278         <xsl:if test="marc:datafield[@tag=250]">
279         <span class="results_summary"><span class="label">Edition: </span>
280             <xsl:for-each select="marc:datafield[@tag=250]">
281                 <xsl:call-template name="chopPunctuation">
282                   <xsl:with-param name="chopString">
283                     <xsl:call-template name="subfieldSelect">
284                         <xsl:with-param name="codes">ab</xsl:with-param>
285                     </xsl:call-template>
286                    </xsl:with-param>
287                </xsl:call-template>
288                     <xsl:choose><xsl:when test="position()=last()"><xsl:text>.</xsl:text></xsl:when><xsl:otherwise><xsl:text>; </xsl:text></xsl:otherwise></xsl:choose>
289             </xsl:for-each>
290         </span>
291         </xsl:if>
292
293         <!-- Description: Alternate Graphic Representation (MARC 880) -->
294         <xsl:if test="$display880">
295             <xsl:call-template name="m880Select">
296                 <xsl:with-param name="basetags">300</xsl:with-param>
297                 <xsl:with-param name="codes">abceg</xsl:with-param>
298                 <xsl:with-param name="class">results_summary</xsl:with-param>
299                 <xsl:with-param name="label">Description: </xsl:with-param>
300             </xsl:call-template>
301         </xsl:if>
302         
303         <xsl:if test="marc:datafield[@tag=300]">
304         <span class="results_summary"><span class="label">Description: </span>
305             <xsl:for-each select="marc:datafield[@tag=300]">
306                 <xsl:call-template name="chopPunctuation">
307                   <xsl:with-param name="chopString">
308                     <xsl:call-template name="subfieldSelect">
309                         <xsl:with-param name="codes">abceg</xsl:with-param>
310                     </xsl:call-template>
311                    </xsl:with-param>
312                </xsl:call-template>
313                     <xsl:choose><xsl:when test="position()=last()"><xsl:text>.</xsl:text></xsl:when><xsl:otherwise><xsl:text>; </xsl:text></xsl:otherwise></xsl:choose>
314             </xsl:for-each>
315         </span>
316        </xsl:if>
317
318        <xsl:if test="marc:datafield[@tag=020]">
319         <span class="results_summary"><span class="label">ISBN: </span>
320         <xsl:for-each select="marc:datafield[@tag=020]">
321         <xsl:variable name="isbn" select="marc:subfield[@code='a']"/>
322                 <xsl:value-of select="marc:subfield[@code='a']"/>
323                 <xsl:choose><xsl:when test="position()=last()"><xsl:text>.</xsl:text></xsl:when><xsl:otherwise><xsl:text>; </xsl:text></xsl:otherwise></xsl:choose>
324         </xsl:for-each>
325         </span>
326         </xsl:if>
327
328         <xsl:if test="marc:datafield[@tag=022]">
329         <span class="results_summary"><span class="label">ISSN: </span>
330         <xsl:for-each select="marc:datafield[@tag=022]">
331                 <xsl:value-of select="marc:subfield[@code='a']"/>
332                 <xsl:choose><xsl:when test="position()=last()"><xsl:text>.</xsl:text></xsl:when><xsl:otherwise><xsl:text>; </xsl:text></xsl:otherwise></xsl:choose>
333         </xsl:for-each>
334         </span>
335         </xsl:if>
336
337         <!-- Other Title  Statement: Alternate Graphic Representation (MARC 880) -->
338         <xsl:if test="$display880">
339             <xsl:call-template name="m880Select">
340                 <xsl:with-param name="basetags">246</xsl:with-param>
341                 <xsl:with-param name="codes">abhfgnp</xsl:with-param>
342                 <xsl:with-param name="class">results_summary</xsl:with-param>
343                 <xsl:with-param name="label">Other Title: </xsl:with-param>
344             </xsl:call-template>
345         </xsl:if>
346
347         <xsl:if test="marc:datafield[@tag=246]">
348         <span class="results_summary"><span class="label">Other Title: </span>
349             <xsl:for-each select="marc:datafield[@tag=246]">
350                 <xsl:call-template name="chopPunctuation">
351                   <xsl:with-param name="chopString">
352                     <xsl:call-template name="subfieldSelect">
353                         <xsl:with-param name="codes">iabhfgnp</xsl:with-param>
354                     </xsl:call-template>
355                    </xsl:with-param>
356                </xsl:call-template>
357                     <xsl:choose><xsl:when test="position()=last()"><xsl:text>.</xsl:text></xsl:when><xsl:otherwise><xsl:text>; </xsl:text></xsl:otherwise></xsl:choose>
358             </xsl:for-each>
359         </span>
360        </xsl:if>
361
362         <!-- Uniform Title  Statement: Alternate Graphic Representation (MARC 880) -->
363         <xsl:if test="$display880">
364             <xsl:call-template name="m880Select">
365                 <xsl:with-param name="basetags">130,240</xsl:with-param>
366                 <xsl:with-param name="codes">adfklmor</xsl:with-param>
367                 <xsl:with-param name="class">results_summary</xsl:with-param>
368                 <xsl:with-param name="label">Uniform Title: </xsl:with-param>
369             </xsl:call-template>
370         </xsl:if>
371
372         <xsl:if test="marc:datafield[@tag=130]|marc:datafield[@tag=240]|marc:datafield[@tag=730][@ind2!=2]">
373         <span class="results_summary"><span class="label">Uniform titles: </span>
374         <xsl:for-each select="marc:datafield[@tag=130]|marc:datafield[@tag=240]|marc:datafield[@tag=730][@ind2!=2]">
375             <xsl:variable name="str">
376                 <xsl:for-each select="marc:subfield">
377                     <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'])))">
378                         <xsl:value-of select="text()"/>
379                         <xsl:text> </xsl:text>
380                      </xsl:if>
381                 </xsl:for-each>
382             </xsl:variable>
383             <xsl:call-template name="chopPunctuation">
384                 <xsl:with-param name="chopString">
385                     <xsl:value-of select="substring($str,1,string-length($str)-1)"/>
386                         
387                 </xsl:with-param>
388             </xsl:call-template>
389             <xsl:choose><xsl:when test="position()=last()"><xsl:text>.</xsl:text></xsl:when><xsl:otherwise><xsl:text>; </xsl:text></xsl:otherwise></xsl:choose>
390         </xsl:for-each>
391         </span>
392         </xsl:if>
393
394         <xsl:if test="marc:datafield[substring(@tag, 1, 1) = '6']">
395             <span class="results_summary"><span class="label">Subject(s): </span>
396             <xsl:for-each select="marc:datafield[substring(@tag, 1, 1) = '6']">
397             <a>
398             <xsl:choose>
399             <xsl:when test="marc:subfield[@code=9]">
400                 <xsl:attribute name="href">/cgi-bin/koha/catalogue/search.pl?q=an:<xsl:value-of select="marc:subfield[@code=9]"/></xsl:attribute>
401             </xsl:when>
402             <xsl:otherwise>
403                 <xsl:attribute name="href">/cgi-bin/koha/catalogue/search.pl?q=su:<xsl:value-of select="marc:subfield[@code='a']"/></xsl:attribute>
404             </xsl:otherwise>
405             </xsl:choose>
406             <xsl:call-template name="chopPunctuation">
407                 <xsl:with-param name="chopString">
408                     <xsl:call-template name="subfieldSelect">
409                         <xsl:with-param name="codes">abcdtvxyz</xsl:with-param>
410                         <xsl:with-param name="subdivCodes">vxyz</xsl:with-param>
411                         <xsl:with-param name="subdivDelimiter">-- </xsl:with-param>
412                     </xsl:call-template>
413                 </xsl:with-param>
414             </xsl:call-template>
415             </a>
416             <xsl:choose>
417             <xsl:when test="position()=last()"></xsl:when>
418             <xsl:otherwise> | </xsl:otherwise>
419             </xsl:choose>
420
421             </xsl:for-each>
422             </span>
423         </xsl:if>
424
425         <xsl:if test="marc:datafield[@tag=856]">
426         <span class="results_summary"><span class="label">Online Resources: </span>
427         <xsl:for-each select="marc:datafield[@tag=856]">
428                                    <a><xsl:attribute name="href"><xsl:value-of select="marc:subfield[@code='u']"/></xsl:attribute>
429                                     <xsl:choose>
430                                     <xsl:when test="marc:subfield[@code='y' or @code='3' or @code='z']">
431                                         <xsl:call-template name="subfieldSelect">
432                                         <xsl:with-param name="codes">y3z</xsl:with-param>
433                                         </xsl:call-template>
434                                     </xsl:when>
435                                     <xsl:when test="not(marc:subfield[@code='y']) and not(marc:subfield[@code='3']) and not(marc:subfield[@code='z'])">
436                                         <xsl:choose>
437                                         <xsl:when test="$URLLinkText!=''">
438                                                 <xsl:value-of select="$URLLinkText"/>
439                                         </xsl:when>
440                                         <xsl:otherwise>
441                                                 <xsl:text>Click here to access online</xsl:text>
442                                         </xsl:otherwise>
443                                         </xsl:choose>
444                                     </xsl:when>
445                                     </xsl:choose>
446                                     </a>
447                                     <xsl:choose>
448                                     <xsl:when test="position()=last()"><xsl:text>  </xsl:text></xsl:when>
449                                     <xsl:otherwise> | </xsl:otherwise>
450                                     </xsl:choose>
451
452         </xsl:for-each>
453         </span>
454         </xsl:if>
455         <xsl:if test="marc:datafield[@tag=505]">
456         <xsl:for-each select="marc:datafield[@tag=505]">
457         <span class="results_summary">
458         <xsl:choose>
459         <xsl:when test="@ind1=0">
460             <span class="label">Contents:</span>
461         </xsl:when>
462         <xsl:when test="@ind1=1">
463             <span class="label">Incomplete contents:</span>
464         </xsl:when>
465         <xsl:when test="@ind1=1">
466             <span class="label">Partial contents:</span>
467         </xsl:when>
468         </xsl:choose>  
469         <xsl:choose>
470         <xsl:when test="@ind2=0">
471             <xsl:for-each select="marc:subfield[@code='t']">
472                 <xsl:value-of select="marc:subfield[@code=t]"/> <xsl:value-of select="marc:subfield[@code=r]"/>
473             </xsl:for-each> 
474         </xsl:when>
475         <xsl:otherwise>
476             <xsl:call-template name="subfieldSelect">
477                 <xsl:with-param name="codes">au</xsl:with-param>
478             </xsl:call-template>
479         </xsl:otherwise>
480         </xsl:choose>
481         </span>
482         </xsl:for-each>
483         </xsl:if>
484
485         <!-- 773 -->
486         <xsl:if test="marc:datafield[@tag=773]">
487         <xsl:for-each select="marc:datafield[@tag=773]">
488         <xsl:if test="@ind1=0">
489         <span class="results_summary"><span class="label">
490         <xsl:choose>
491         <xsl:when test="@ind2=' '">
492             In:
493         </xsl:when>
494         <xsl:when test="@ind2=8">
495             <xsl:if test="marc:subfield[@code='i']">
496                 <xsl:value-of select="marc:subfield[@code='i']"/>
497             </xsl:if>
498         </xsl:when>
499         </xsl:choose>
500         </span>
501                 <xsl:variable name="f773">
502                     <xsl:call-template name="subfieldSelect">
503                         <xsl:with-param name="codes">at</xsl:with-param>
504                     </xsl:call-template>
505                 </xsl:variable>
506              <a><xsl:attribute name="href">/cgi-bin/koha/catalogue/search.pl?q=Title:<xsl:value-of select="translate($f773, '()', '')"/></xsl:attribute>
507                 <xsl:value-of select="$f773"/>
508             </a>
509         </span>
510
511         <xsl:if test="marc:subfield[@code='n']">
512             <span class="results_summary"><xsl:value-of select="marc:subfield[@code='n']"/></span>
513         </xsl:if>
514
515         </xsl:if>
516         </xsl:for-each>
517         </xsl:if>
518
519         <!-- 780 -->
520         <xsl:if test="marc:datafield[@tag=780]">
521         <xsl:for-each select="marc:datafield[@tag=780]">
522         <span class="results_summary">
523         <xsl:choose>
524         <xsl:when test="@ind2=0">
525             <span class="label">Continues:</span>
526         </xsl:when>
527         <xsl:when test="@ind2=1">
528             <span class="label">Continues in part:</span>
529         </xsl:when>
530         <xsl:when test="@ind2=2">
531             <span class="label">Supersedes:</span>
532         </xsl:when>
533         <xsl:when test="@ind2=3">
534             <span class="label">Supersedes in part:</span>
535         </xsl:when>
536         <xsl:when test="@ind2=4">
537             <span class="label">Formed by the union: ... and: ...</span>
538         </xsl:when>
539         <xsl:when test="@ind2=5">
540             <span class="label">Absorbed:</span>
541         </xsl:when>
542         <xsl:when test="@ind2=6">
543             <span class="label">Absorbed in part:</span>
544         </xsl:when>
545         <xsl:when test="@ind2=7">
546             <span class="label">Separated from:</span>
547         </xsl:when>
548         </xsl:choose>
549                 <xsl:variable name="f780">
550                     <xsl:call-template name="subfieldSelect">
551                         <xsl:with-param name="codes">at</xsl:with-param>
552                     </xsl:call-template>
553                 </xsl:variable>
554              <a><xsl:attribute name="href">/cgi-bin/koha/catalogue/search.pl?q=<xsl:value-of select="translate($f780, '()', '')"/></xsl:attribute>
555                 <xsl:value-of select="translate($f780, '()', '')"/>
556             </a>
557         </span>
558  
559         <xsl:choose>
560         <xsl:when test="@ind1=0">
561             <span class="results_summary"><xsl:value-of select="marc:subfield[@code='n']"/></span>
562         </xsl:when>
563         </xsl:choose>
564
565         </xsl:for-each>
566         </xsl:if>
567
568         <!-- 785 -->
569         <xsl:if test="marc:datafield[@tag=785]">
570         <xsl:for-each select="marc:datafield[@tag=785]">
571         <span class="results_summary">
572         <xsl:choose>
573         <xsl:when test="@ind2=0">
574             <span class="label">Continued by:</span>
575         </xsl:when>
576         <xsl:when test="@ind2=1">
577             <span class="label">Continued in part by:</span>
578         </xsl:when>
579         <xsl:when test="@ind2=2">
580             <span class="label">Superseded by:</span>
581         </xsl:when>
582         <xsl:when test="@ind2=3">
583             <span class="label">Superseded in part by:</span>
584         </xsl:when>
585         <xsl:when test="@ind2=4">
586             <span class="label">Absorbed by:</span>
587         </xsl:when>
588         <xsl:when test="@ind2=5">
589             <span class="label">Absorbed in part by:</span>
590         </xsl:when>
591         <xsl:when test="@ind2=6">
592             <span class="label">Split into .. and ...:</span>
593         </xsl:when>
594         <xsl:when test="@ind2=7">
595             <span class="label">Merged with ... to form ...</span>
596         </xsl:when>
597         <xsl:when test="@ind2=8">
598             <span class="label">Changed back to:</span>
599         </xsl:when>
600
601         </xsl:choose>
602                    <xsl:variable name="f785">
603                     <xsl:call-template name="subfieldSelect">
604                         <xsl:with-param name="codes">at</xsl:with-param>
605                     </xsl:call-template>
606                 </xsl:variable>
607
608                 <a><xsl:attribute name="href">/cgi-bin/koha/catalogue/search.pl?q=<xsl:value-of select="translate($f785, '()', '')"/></xsl:attribute>
609                 <xsl:value-of select="translate($f785, '()', '')"/>
610             </a>
611
612         </span>
613         </xsl:for-each>
614         </xsl:if>
615
616         <xsl:if test="$OPACBaseURL!=''">
617         <span class="results_summary"><span class="label">OPAC view: </span>
618             <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>.
619         </span>
620         </xsl:if>
621
622     </xsl:template>
623
624     <xsl:template name="nameABCDQ">
625             <xsl:call-template name="chopPunctuation">
626                 <xsl:with-param name="chopString">
627                     <xsl:call-template name="subfieldSelect">
628                         <xsl:with-param name="codes">aq</xsl:with-param>
629                     </xsl:call-template>
630                 </xsl:with-param>
631                 <xsl:with-param name="punctuation">
632                     <xsl:text>:,;/ </xsl:text>
633                 </xsl:with-param>
634             </xsl:call-template>
635         <xsl:call-template name="termsOfAddress"/>
636     </xsl:template>
637
638     <xsl:template name="nameABCDN">
639         <xsl:for-each select="marc:subfield[@code='a']">
640                 <xsl:call-template name="chopPunctuation">
641                     <xsl:with-param name="chopString" select="."/>
642                 </xsl:call-template>
643         </xsl:for-each>
644         <xsl:for-each select="marc:subfield[@code='b']">
645                 <xsl:value-of select="."/>
646         </xsl:for-each>
647         <xsl:if test="marc:subfield[@code='c'] or marc:subfield[@code='d'] or marc:subfield[@code='n']">
648                 <xsl:call-template name="subfieldSelect">
649                     <xsl:with-param name="codes">cdn</xsl:with-param>
650                 </xsl:call-template>
651         </xsl:if>
652     </xsl:template>
653
654     <xsl:template name="nameACDEQ">
655             <xsl:call-template name="subfieldSelect">
656                 <xsl:with-param name="codes">acdeq</xsl:with-param>
657             </xsl:call-template>
658     </xsl:template>
659     <xsl:template name="termsOfAddress">
660         <xsl:if test="marc:subfield[@code='b' or @code='c']">
661             <xsl:call-template name="chopPunctuation">
662                 <xsl:with-param name="chopString">
663                     <xsl:call-template name="subfieldSelect">
664                         <xsl:with-param name="codes">bc</xsl:with-param>
665                     </xsl:call-template>
666                 </xsl:with-param>
667             </xsl:call-template>
668         </xsl:if>
669     </xsl:template>
670
671     <xsl:template name="part">
672         <xsl:variable name="partNumber">
673             <xsl:call-template name="specialSubfieldSelect">
674                 <xsl:with-param name="axis">n</xsl:with-param>
675                 <xsl:with-param name="anyCodes">n</xsl:with-param>
676                 <xsl:with-param name="afterCodes">fghkdlmor</xsl:with-param>
677             </xsl:call-template>
678         </xsl:variable>
679         <xsl:variable name="partName">
680             <xsl:call-template name="specialSubfieldSelect">
681                 <xsl:with-param name="axis">p</xsl:with-param>
682                 <xsl:with-param name="anyCodes">p</xsl:with-param>
683                 <xsl:with-param name="afterCodes">fghkdlmor</xsl:with-param>
684             </xsl:call-template>
685         </xsl:variable>
686         <xsl:if test="string-length(normalize-space($partNumber))">
687                 <xsl:call-template name="chopPunctuation">
688                     <xsl:with-param name="chopString" select="$partNumber"/>
689                 </xsl:call-template>
690         </xsl:if>
691         <xsl:if test="string-length(normalize-space($partName))">
692                 <xsl:call-template name="chopPunctuation">
693                     <xsl:with-param name="chopString" select="$partName"/>
694                 </xsl:call-template>
695         </xsl:if>
696     </xsl:template>
697
698     <xsl:template name="specialSubfieldSelect">
699         <xsl:param name="anyCodes"/>
700         <xsl:param name="axis"/>
701         <xsl:param name="beforeCodes"/>
702         <xsl:param name="afterCodes"/>
703         <xsl:variable name="str">
704             <xsl:for-each select="marc:subfield">
705                 <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])">
706                     <xsl:value-of select="text()"/>
707                     <xsl:text> </xsl:text>
708                 </xsl:if>
709             </xsl:for-each>
710         </xsl:variable>
711         <xsl:value-of select="substring($str,1,string-length($str)-1)"/>
712     </xsl:template>
713
714 </xsl:stylesheet>