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