Bug 7845: Multiple 260s don't display properly in search results
[koha.git] / koha-tmpl / opac-tmpl / prog / en / xslt / MARC21slim2OPACDetail.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 <!DOCTYPE stylesheet [<!ENTITY nbsp "&#160;" >]>
4 <xsl:stylesheet version="1.0"
5   xmlns:marc="http://www.loc.gov/MARC21/slim"
6   xmlns:items="http://www.koha-community.org/items"
7   xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
8   exclude-result-prefixes="marc items">
9     <xsl:import href="MARC21slimUtils.xsl"/>
10     <xsl:output method = "xml" indent="yes" omit-xml-declaration = "yes" />
11     <xsl:template match="/">
12             <xsl:apply-templates/>
13     </xsl:template>
14
15     <xsl:template match="marc:record">
16
17         <!-- Option: Display Alternate Graphic Representation (MARC 880)  -->
18         <xsl:variable name="display880" select="boolean(marc:datafield[@tag=880])"/>
19
20     <xsl:variable name="UseControlNumber" select="marc:sysprefs/marc:syspref[@name='UseControlNumber']"/>
21     <xsl:variable name="DisplayOPACiconsXSLT" select="marc:sysprefs/marc:syspref[@name='DisplayOPACiconsXSLT']"/>
22     <xsl:variable name="OPACURLOpenInNewWindow" select="marc:sysprefs/marc:syspref[@name='OPACURLOpenInNewWindow']"/>
23     <xsl:variable name="URLLinkText" select="marc:sysprefs/marc:syspref[@name='URLLinkText']"/>
24     <xsl:variable name="ShowISBD" select="marc:sysprefs/marc:syspref[@name='viewISBD']"/>
25     
26     <xsl:variable name="SubjectModifier"><xsl:if test="marc:sysprefs/marc:syspref[@name='TraceCompleteSubfields']='1'">,complete-subfield</xsl:if></xsl:variable>
27     <xsl:variable name="UseAuthoritiesForTracings" select="marc:sysprefs/marc:syspref[@name='UseAuthoritiesForTracings']"/>
28     <xsl:variable name="TraceSubjectSubdivisions" select="marc:sysprefs/marc:syspref[@name='TraceSubjectSubdivisions']"/>
29     <xsl:variable name="Show856uAsImage" select="marc:sysprefs/marc:syspref[@name='OPACDisplay856uAsImage']"/>
30     <xsl:variable name="TracingQuotesLeft">
31       <xsl:choose>
32         <xsl:when test="marc:sysprefs/marc:syspref[@name='UseICU']='1'">{</xsl:when>
33         <xsl:otherwise>"</xsl:otherwise>
34       </xsl:choose>
35     </xsl:variable>
36     <xsl:variable name="TracingQuotesRight">
37       <xsl:choose>
38         <xsl:when test="marc:sysprefs/marc:syspref[@name='UseICU']='1'">}</xsl:when>
39         <xsl:otherwise>"</xsl:otherwise>
40       </xsl:choose>
41     </xsl:variable>
42         <xsl:variable name="leader" select="marc:leader"/>
43         <xsl:variable name="leader6" select="substring($leader,7,1)"/>
44         <xsl:variable name="leader7" select="substring($leader,8,1)"/>
45         <xsl:variable name="leader19" select="substring($leader,20,1)"/>
46         <xsl:variable name="controlField008" select="marc:controlfield[@tag=008]"/>
47         <xsl:variable name="materialTypeCode">
48             <xsl:choose>
49                 <xsl:when test="$leader19='a'">ST</xsl:when>
50                 <xsl:when test="$leader6='a'">
51                     <xsl:choose>
52                         <xsl:when test="$leader7='c' or $leader7='d' or $leader7='m'">BK</xsl:when>
53                         <xsl:when test="$leader7='i' or $leader7='s'">SE</xsl:when>
54                         <xsl:when test="$leader7='a' or $leader7='b'">AR</xsl:when>
55                     </xsl:choose>
56                 </xsl:when>
57                 <xsl:when test="$leader6='t'">BK</xsl:when>
58                 <xsl:when test="$leader6='o' or $leader6='p'">MX</xsl:when>
59                 <xsl:when test="$leader6='m'">CF</xsl:when>
60                 <xsl:when test="$leader6='e' or $leader6='f'">MP</xsl:when>
61                 <xsl:when test="$leader6='g' or $leader6='k' or $leader6='r'">VM</xsl:when>
62                 <xsl:when test="$leader6='i' or $leader6='j'">MU</xsl:when>
63                 <xsl:when test="$leader6='c' or $leader6='d'">PR</xsl:when>
64             </xsl:choose>
65         </xsl:variable>
66         <xsl:variable name="materialTypeLabel">
67             <xsl:choose>
68                 <xsl:when test="$leader19='a'">Set</xsl:when>
69                 <xsl:when test="$leader6='a'">
70                     <xsl:choose>
71                         <xsl:when test="$leader7='c' or $leader7='d' or $leader7='m'">Book</xsl:when>
72                         <xsl:when test="$leader7='i' or $leader7='s'">
73                             <xsl:choose>
74                                 <xsl:when test="substring($controlField008,22,1)!='m'">Continuing Resource</xsl:when>
75                                 <xsl:otherwise>Series</xsl:otherwise>
76                             </xsl:choose>
77                         </xsl:when>
78                         <xsl:when test="$leader7='a' or $leader7='b'">Article</xsl:when>
79                     </xsl:choose>
80                 </xsl:when>
81                 <xsl:when test="$leader6='t'">Book</xsl:when>
82                                 <xsl:when test="$leader6='o'">Kit</xsl:when>
83                 <xsl:when test="$leader6='p'">Mixed Materials</xsl:when>
84                 <xsl:when test="$leader6='m'">Computer File</xsl:when>
85                 <xsl:when test="$leader6='e' or $leader6='f'">Map</xsl:when>
86                 <xsl:when test="$leader6='g' or $leader6='k' or $leader6='r'">Visual Material</xsl:when>
87                 <xsl:when test="$leader6='j'">Music</xsl:when>
88                 <xsl:when test="$leader6='i'">Sound</xsl:when>
89                 <xsl:when test="$leader6='c' or $leader6='d'">Score</xsl:when>
90             </xsl:choose>
91         </xsl:variable>
92
93         <!-- Title Statement -->
94         <!-- Alternate Graphic Representation (MARC 880) -->
95         <xsl:if test="$display880">
96             <h1 class="title">
97                 <xsl:call-template name="m880Select">
98                     <xsl:with-param name="basetags">245</xsl:with-param>
99                     <xsl:with-param name="codes">abhfgknps</xsl:with-param>
100                 </xsl:call-template>
101             </h1>
102         </xsl:if>
103
104         <xsl:if test="marc:datafield[@tag=245]">
105         <h1 class="title">
106             <xsl:for-each select="marc:datafield[@tag=245]">
107                     <xsl:call-template name="subfieldSelect">
108                         <xsl:with-param name="codes">a</xsl:with-param>
109                     </xsl:call-template>
110                     <xsl:if test="marc:subfield[@code='h']">
111                         <xsl:text> </xsl:text>
112                         <xsl:call-template name="subfieldSelect">
113                             <xsl:with-param name="codes">h</xsl:with-param>
114                         </xsl:call-template>
115                     </xsl:if>
116                     <xsl:if test="marc:subfield[@code='b']">
117                         <xsl:text> </xsl:text>
118                         <xsl:call-template name="subfieldSelect">
119                             <xsl:with-param name="codes">b</xsl:with-param>
120                         </xsl:call-template>
121                     </xsl:if>
122                 <xsl:text> </xsl:text>
123                     <xsl:call-template name="subfieldSelect">
124                         <xsl:with-param name="codes">fgknps</xsl:with-param>
125                     </xsl:call-template>
126             </xsl:for-each>
127         </h1>
128         </xsl:if>
129
130         <!-- Author Statement: Alternate Graphic Representation (MARC 880) -->
131         <xsl:if test="$display880">
132             <h5 class="author">
133                 <xsl:call-template name="m880Select">
134                     <xsl:with-param name="basetags">100,110,111,700,710,711</xsl:with-param>
135                     <xsl:with-param name="codes">abc</xsl:with-param>
136                     <xsl:with-param name="index">au</xsl:with-param>
137                     <!-- do not use label 'by ' here, it would be repeated for every occurence of 100,110,111,700,710,711 -->
138                 </xsl:call-template>
139             </h5>
140         </xsl:if>
141         <xsl:choose>
142             <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]">
143                 <h5 class="author">by
144                     <xsl:call-template name="showAuthor">
145                         <xsl:with-param name="authorfield" select="marc:datafield[@tag=100 or @tag=110 or @tag=111 or @tag=700 or @tag=710 or @tag=711]"/>
146                         <xsl:with-param name="UseAuthoritiesForTracings" select="$UseAuthoritiesForTracings"/>
147                     </xsl:call-template>
148                 </h5>
149             </xsl:when>
150         </xsl:choose>
151
152    <xsl:if test="$DisplayOPACiconsXSLT!='0'">
153         <xsl:if test="$materialTypeCode!=''">
154         <span class="results_summary type"><span class="label">Type: </span>
155         <xsl:element name="img"><xsl:attribute name="src">/opac-tmpl/prog/famfamfam/<xsl:value-of select="$materialTypeCode"/>.png</xsl:attribute><xsl:attribute name="alt">materialTypeLabel</xsl:attribute><xsl:attribute name="class">materialtype</xsl:attribute></xsl:element>
156         <xsl:value-of select="$materialTypeLabel"/>
157         </span>
158         </xsl:if>
159    </xsl:if>
160
161         <!--Series: Alternate Graphic Representation (MARC 880) -->
162         <xsl:if test="$display880">
163             <xsl:call-template name="m880Select">
164                 <xsl:with-param name="basetags">440,490</xsl:with-param>
165                 <xsl:with-param name="codes">av</xsl:with-param>
166                 <xsl:with-param name="class">results_summary series</xsl:with-param>
167                 <xsl:with-param name="label">Series: </xsl:with-param>
168                 <xsl:with-param name="index">se</xsl:with-param>
169             </xsl:call-template>
170         </xsl:if>
171
172         <!-- Series -->
173         <xsl:if test="marc:datafield[@tag=440 or @tag=490]">
174         <span class="results_summary series"><span class="label">Series: </span>
175         <!-- 440 -->
176         <xsl:for-each select="marc:datafield[@tag=440]">
177             <a><xsl:attribute name="href">/cgi-bin/koha/opac-search.pl?q=se,phr:"<xsl:value-of select="marc:subfield[@code='a']"/>"</xsl:attribute>
178             <xsl:call-template name="chopPunctuation">
179                             <xsl:with-param name="chopString">
180                                 <xsl:call-template name="subfieldSelect">
181                                     <xsl:with-param name="codes">av</xsl:with-param>
182                                 </xsl:call-template>
183                             </xsl:with-param>
184                         </xsl:call-template>
185                         </a>
186                     <xsl:text> </xsl:text><xsl:call-template name="part"/>
187             <xsl:choose><xsl:when test="position()=last()"><xsl:text>.</xsl:text></xsl:when><xsl:otherwise><xsl:text>; </xsl:text></xsl:otherwise></xsl:choose>
188         </xsl:for-each>
189
190         <!-- 490 Series not traced, Ind1 = 0 -->
191         <xsl:for-each select="marc:datafield[@tag=490][@ind1!=1]">
192             <a><xsl:attribute name="href">/cgi-bin/koha/opac-search.pl?q=se,phr:"<xsl:value-of select="marc:subfield[@code='a']"/>"</xsl:attribute>
193                         <xsl:call-template name="chopPunctuation">
194                             <xsl:with-param name="chopString">
195                                 <xsl:call-template name="subfieldSelect">
196                                     <xsl:with-param name="codes">av</xsl:with-param>
197                                 </xsl:call-template>
198                             </xsl:with-param>
199                         </xsl:call-template>
200             </a>
201                     <xsl:call-template name="part"/>
202         <xsl:choose><xsl:when test="position()=last()"><xsl:text>.</xsl:text></xsl:when><xsl:otherwise><xsl:text>; </xsl:text></xsl:otherwise></xsl:choose>
203         </xsl:for-each>
204         <!-- 490 Series traced, Ind1 = 1 -->
205         <xsl:if test="marc:datafield[@tag=490][@ind1=1]">
206             <xsl:for-each select="marc:datafield[@tag=800 or @tag=810 or @tag=811 or @tag=830]">
207                 <xsl:choose>
208                     <xsl:when test="$UseControlNumber = '1' and marc:subfield[@code='w']">
209                         <a href="/cgi-bin/koha/opac-search.pl?q=rcn:{marc:subfield[@code='w']}">
210                             <xsl:call-template name="chopPunctuation">
211                                 <xsl:with-param name="chopString">
212                                     <xsl:call-template name="subfieldSelect">
213                                         <xsl:with-param name="codes">a_t</xsl:with-param>
214                                     </xsl:call-template>
215                                 </xsl:with-param>
216                             </xsl:call-template>
217                         </a>
218                     </xsl:when>
219                     <xsl:otherwise>
220                         <a><xsl:attribute name="href">/cgi-bin/koha/opac-search.pl?q=se,phr:"<xsl:value-of select="marc:subfield[@code='a']"/>"</xsl:attribute>
221                             <xsl:call-template name="chopPunctuation">
222                                 <xsl:with-param name="chopString">
223                                     <xsl:call-template name="subfieldSelect">
224                                         <xsl:with-param name="codes">a_t</xsl:with-param>
225                                     </xsl:call-template>
226                                 </xsl:with-param>
227                             </xsl:call-template>
228                         </a>
229                         <xsl:call-template name="part"/>
230                     </xsl:otherwise>
231                 </xsl:choose>
232                 <xsl:text>: </xsl:text>
233                 <xsl:value-of  select="marc:subfield[@code='v']" />
234             <xsl:choose><xsl:when test="position()=last()"><xsl:text></xsl:text></xsl:when><xsl:otherwise><xsl:text>; </xsl:text></xsl:otherwise></xsl:choose>
235             </xsl:for-each>
236         </xsl:if>
237         </span>
238         </xsl:if>
239         
240         <!-- Analytics -->
241         <xsl:if test="$leader7='s'">
242         <span class="results_summary analytics"><span class="label">Analytics: </span>
243             <a>
244             <xsl:choose>
245             <xsl:when test="$UseControlNumber = '1' and marc:controlfield[@tag=001]">
246                 <xsl:attribute name="href">/cgi-bin/koha/opac-search.pl?q=rcn:<xsl:value-of select="marc:controlfield[@tag=001]"/>+and+(bib-level:a+or+bib-level:b)</xsl:attribute>
247             </xsl:when>
248             <xsl:otherwise>
249                 <xsl:attribute name="href">/cgi-bin/koha/opac-search.pl?q=Host-item:<xsl:value-of select="translate(marc:datafield[@tag=245]/marc:subfield[@code='a'], '/', '')"/></xsl:attribute>
250             </xsl:otherwise>
251             </xsl:choose>
252             <xsl:text>Show analytics</xsl:text>
253             </a>
254         </span>
255         </xsl:if>
256
257         <!-- Volumes of sets and traced series -->
258         <xsl:if test="$materialTypeCode='ST' or substring($controlField008,22,1)='m'">
259         <span class="results_summary volumes"><span class="label">Volumes: </span>
260             <a>
261             <xsl:choose>
262             <xsl:when test="$UseControlNumber = '1' and marc:controlfield[@tag=001]">
263                 <xsl:attribute name="href">/cgi-bin/koha/opac-search.pl?q=rcn:<xsl:value-of select="marc:controlfield[@tag=001]"/>+not+(bib-level:a+or+bib-level:b)</xsl:attribute>
264             </xsl:when>
265             <xsl:otherwise>
266                 <xsl:attribute name="href">/cgi-bin/koha/opac-search.pl?q=ti,phr:<xsl:value-of select="translate(marc:datafield[@tag=245]/marc:subfield[@code='a'], '/', '')"/></xsl:attribute>
267             </xsl:otherwise>
268             </xsl:choose>
269             <xsl:text>Show volumes</xsl:text>
270             </a>
271         </span>
272         </xsl:if>
273
274         <!-- Set -->
275         <xsl:if test="$leader19='c'">
276         <span class="results_summary set"><span class="label">Set: </span>
277         <xsl:for-each select="marc:datafield[@tag=773]">
278             <a>
279             <xsl:choose>
280             <xsl:when test="$UseControlNumber = '1' and marc:subfield[@code='w']">
281                 <xsl:attribute name="href">/cgi-bin/koha/opac-search.pl?q=Control-number:<xsl:call-template name="extractControlNumber"><xsl:with-param name="subfieldW" select="marc:subfield[@code='w']"/></xsl:call-template></xsl:attribute>
282             </xsl:when>
283             <xsl:otherwise>
284                 <xsl:attribute name="href">/cgi-bin/koha/opac-search.pl?q=ti,phr:<xsl:value-of select="translate(//marc:datafield[@tag=245]/marc:subfield[@code='a'], '.', '')"/></xsl:attribute>
285             </xsl:otherwise>
286             </xsl:choose>
287             <xsl:value-of select="translate(//marc:datafield[@tag=245]/marc:subfield[@code='a'], '.', '')" />
288             </a>
289             <xsl:choose>
290                 <xsl:when test="position()=last()"></xsl:when>
291                 <xsl:otherwise><xsl:text>; </xsl:text></xsl:otherwise>
292             </xsl:choose>
293         </xsl:for-each>
294         </span>
295         </xsl:if>
296
297         <!-- Publisher Statement: Alternate Graphic Representation (MARC 880) -->
298         <xsl:if test="$display880">
299             <xsl:call-template name="m880Select">
300                 <xsl:with-param name="basetags">260</xsl:with-param>
301                 <xsl:with-param name="codes">abcg</xsl:with-param>
302                 <xsl:with-param name="class">results_summary publisher</xsl:with-param>
303                 <xsl:with-param name="label">Publisher: </xsl:with-param>
304             </xsl:call-template>
305         </xsl:if>
306
307         <xsl:if test="marc:datafield[@tag=260]">
308         <span class="results_summary publisher"><span class="label">Publisher: </span>
309             <xsl:for-each select="marc:datafield[@tag=260]">
310                 <xsl:if test="marc:subfield[@code='a']">
311                     <xsl:call-template name="subfieldSelect">
312                         <xsl:with-param name="codes">a</xsl:with-param>
313                     </xsl:call-template>
314                 </xsl:if>
315                 <xsl:text> </xsl:text>
316                 <xsl:if test="marc:subfield[@code='b']">
317                 <a href="/cgi-bin/koha/opac-search.pl?q=pb:{marc:subfield[@code='b']}">
318                     <xsl:call-template name="subfieldSelect">
319                         <xsl:with-param name="codes">b</xsl:with-param>
320                     </xsl:call-template>
321                </a>
322                </xsl:if>
323                <xsl:text> </xsl:text>
324                 <xsl:call-template name="chopPunctuation">
325                   <xsl:with-param name="chopString">
326                     <xsl:call-template name="subfieldSelect">
327                         <xsl:with-param name="codes">cg</xsl:with-param>
328                     </xsl:call-template>
329                    </xsl:with-param>
330                </xsl:call-template>
331                     <xsl:choose><xsl:when test="position()=last()"><xsl:text></xsl:text></xsl:when><xsl:otherwise><xsl:text>; </xsl:text></xsl:otherwise></xsl:choose>
332             </xsl:for-each>
333         </span>
334         </xsl:if>
335
336         <!-- Edition Statement: Alternate Graphic Representation (MARC 880) -->
337         <xsl:if test="$display880">
338             <xsl:call-template name="m880Select">
339                 <xsl:with-param name="basetags">250</xsl:with-param>
340                 <xsl:with-param name="codes">ab</xsl:with-param>
341                 <xsl:with-param name="class">results_summary edition</xsl:with-param>
342                 <xsl:with-param name="label">Edition: </xsl:with-param>
343             </xsl:call-template>
344         </xsl:if>
345
346         <xsl:if test="marc:datafield[@tag=250]">
347         <span class="results_summary edition"><span class="label">Edition: </span>
348             <xsl:for-each select="marc:datafield[@tag=250]">
349                 <xsl:call-template name="chopPunctuation">
350                   <xsl:with-param name="chopString">
351                     <xsl:call-template name="subfieldSelect">
352                         <xsl:with-param name="codes">ab</xsl:with-param>
353                     </xsl:call-template>
354                    </xsl:with-param>
355                </xsl:call-template>
356                     <xsl:choose><xsl:when test="position()=last()"><xsl:text>.</xsl:text></xsl:when><xsl:otherwise><xsl:text>; </xsl:text></xsl:otherwise></xsl:choose>
357             </xsl:for-each>
358         </span>
359         </xsl:if>
360
361         <!-- Description: Alternate Graphic Representation (MARC 880) -->
362         <xsl:if test="$display880">
363             <xsl:call-template name="m880Select">
364                 <xsl:with-param name="basetags">300</xsl:with-param>
365                 <xsl:with-param name="codes">abceg</xsl:with-param>
366                 <xsl:with-param name="class">results_summary description</xsl:with-param>
367                 <xsl:with-param name="label">Description: </xsl:with-param>
368             </xsl:call-template>
369         </xsl:if>
370
371         <xsl:if test="marc:datafield[@tag=300]">
372         <span class="results_summary description"><span class="label">Description: </span>
373             <xsl:for-each select="marc:datafield[@tag=300]">
374                 <xsl:call-template name="chopPunctuation">
375                   <xsl:with-param name="chopString">
376                     <xsl:call-template name="subfieldSelect">
377                         <xsl:with-param name="codes">abceg</xsl:with-param>
378                     </xsl:call-template>
379                    </xsl:with-param>
380                </xsl:call-template>
381                     <xsl:choose><xsl:when test="position()=last()"><xsl:text>.</xsl:text></xsl:when><xsl:otherwise><xsl:text>; </xsl:text></xsl:otherwise></xsl:choose>
382             </xsl:for-each>
383         </span>
384        </xsl:if>
385
386        <xsl:if test="marc:datafield[@tag=020]">
387         <span class="results_summary isbn"><span class="label">ISBN: </span>
388         <xsl:for-each select="marc:datafield[@tag=020]">
389         <xsl:variable name="isbn" select="marc:subfield[@code='a']"/>
390                 <xsl:value-of select="marc:subfield[@code='a']"/>
391                 <xsl:choose><xsl:when test="position()=last()"><xsl:text>.</xsl:text></xsl:when><xsl:otherwise><xsl:text>; </xsl:text></xsl:otherwise></xsl:choose>
392         </xsl:for-each>
393         </span>
394         </xsl:if>
395
396         <xsl:if test="marc:datafield[@tag=022]">
397         <span class="results_summary issn"><span class="label">ISSN: </span>
398         <xsl:for-each select="marc:datafield[@tag=022]">
399                 <xsl:value-of select="marc:subfield[@code='a']"/>
400                 <xsl:choose><xsl:when test="position()=last()"><xsl:text>.</xsl:text></xsl:when><xsl:otherwise><xsl:text>; </xsl:text></xsl:otherwise></xsl:choose>
401         </xsl:for-each>
402         </span>
403         </xsl:if>
404
405         <!-- Other Title  Statement: Alternate Graphic Representation (MARC 880) -->
406         <xsl:if test="$display880">
407             <xsl:call-template name="m880Select">
408                 <xsl:with-param name="basetags">246</xsl:with-param>
409                 <xsl:with-param name="codes">abhfgnp</xsl:with-param>
410                 <xsl:with-param name="class">results_summary other_title</xsl:with-param>
411                 <xsl:with-param name="label">Other Title: </xsl:with-param>
412             </xsl:call-template>
413         </xsl:if>
414
415         <xsl:if test="marc:datafield[@tag=246]">
416         <span class="results_summary other_title"><span class="label">Other Title: </span>
417             <xsl:for-each select="marc:datafield[@tag=246]">
418                 <xsl:call-template name="chopPunctuation">
419                   <xsl:with-param name="chopString">
420                     <xsl:call-template name="subfieldSelect">
421                         <xsl:with-param name="codes">iabhfgnp</xsl:with-param>
422                     </xsl:call-template>
423                    </xsl:with-param>
424                </xsl:call-template>
425                     <xsl:choose><xsl:when test="position()=last()"><xsl:text>.</xsl:text></xsl:when><xsl:otherwise><xsl:text>; </xsl:text></xsl:otherwise></xsl:choose>
426             </xsl:for-each>
427         </span>
428        </xsl:if>
429
430
431         <xsl:if test="marc:datafield[@tag=242]">
432         <span class="results_summary translated_title"><span class="label">Title translated: </span>
433             <xsl:for-each select="marc:datafield[@tag=242]">
434                 <xsl:call-template name="chopPunctuation">
435                   <xsl:with-param name="chopString">
436                     <xsl:call-template name="subfieldSelect">
437                         <xsl:with-param name="codes">abchnp</xsl:with-param>
438                     </xsl:call-template>
439                    </xsl:with-param>
440                </xsl:call-template>
441                     <xsl:choose><xsl:when test="position()=last()"><xsl:text>.</xsl:text></xsl:when><xsl:otherwise><xsl:text>; </xsl:text></xsl:otherwise></xsl:choose>
442             </xsl:for-each>
443         </span>
444        </xsl:if>
445
446         <!-- Uniform Title  Statement: Alternate Graphic Representation (MARC 880) -->
447         <xsl:if test="$display880">
448             <xsl:call-template name="m880Select">
449                 <xsl:with-param name="basetags">130,240</xsl:with-param>
450                 <xsl:with-param name="codes">adfklmor</xsl:with-param>
451                 <xsl:with-param name="class">results_summary uniform_title</xsl:with-param>
452                 <xsl:with-param name="label">Uniform titles: </xsl:with-param>
453             </xsl:call-template>
454         </xsl:if>
455
456         <xsl:if test="marc:datafield[@tag=130]|marc:datafield[@tag=240]|marc:datafield[@tag=730][@ind2!=2]">
457         <span class="results_summary uniform_titles"><span class="label">Uniform titles: </span>
458         <xsl:for-each select="marc:datafield[@tag=130]|marc:datafield[@tag=240]|marc:datafield[@tag=730][@ind2!=2]">
459             <xsl:variable name="str">
460                 <xsl:for-each select="marc:subfield">
461                     <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'])))">
462                         <xsl:value-of select="text()"/>
463                         <xsl:text> </xsl:text>
464                      </xsl:if>
465                 </xsl:for-each>
466             </xsl:variable>
467             <xsl:call-template name="chopPunctuation">
468                 <xsl:with-param name="chopString">
469                     <xsl:value-of select="substring($str,1,string-length($str)-1)"/>
470
471                 </xsl:with-param>
472             </xsl:call-template>
473             <xsl:choose><xsl:when test="position()=last()"><xsl:text>.</xsl:text></xsl:when><xsl:otherwise><xsl:text>; </xsl:text></xsl:otherwise></xsl:choose>
474         </xsl:for-each>
475         </span>
476         </xsl:if>
477
478         <xsl:if test="marc:datafield[substring(@tag, 1, 1) = '6']">
479             <span class="results_summary subjects"><span class="label">Subject(s): </span>
480             <xsl:for-each select="marc:datafield[substring(@tag, 1, 1) = '6']">
481             <a>
482             <xsl:choose>
483             <xsl:when test="marc:subfield[@code=9] and $UseAuthoritiesForTracings='1'">
484                 <xsl:attribute name="href">/cgi-bin/koha/opac-search.pl?q=an:<xsl:value-of select="marc:subfield[@code=9]"/></xsl:attribute>
485             </xsl:when>
486             <xsl:when test="$TraceSubjectSubdivisions='1'">
487                 <xsl:attribute name="href">/cgi-bin/koha/opac-search.pl?q=<xsl:call-template name="subfieldSelect">
488                         <xsl:with-param name="codes">abcdfgklmnopqrstvxyz</xsl:with-param>
489                         <xsl:with-param name="delimeter"> AND </xsl:with-param>
490                         <xsl:with-param name="prefix">(su<xsl:value-of select="$SubjectModifier"/>:<xsl:value-of select="$TracingQuotesLeft"/></xsl:with-param>
491                         <xsl:with-param name="suffix"><xsl:value-of select="$TracingQuotesRight"/>)</xsl:with-param>
492                     </xsl:call-template>
493                 </xsl:attribute>
494             </xsl:when>
495             <xsl:otherwise>
496                 <xsl:attribute name="href">/cgi-bin/koha/opac-search.pl?q=su<xsl:value-of select="$SubjectModifier"/>:<xsl:value-of select="$TracingQuotesLeft"/><xsl:value-of select="marc:subfield[@code='a']"/><xsl:value-of select="$TracingQuotesRight"/></xsl:attribute>
497             </xsl:otherwise>
498             </xsl:choose>
499             <xsl:call-template name="chopPunctuation">
500                 <xsl:with-param name="chopString">
501                     <xsl:call-template name="subfieldSelect">
502                         <xsl:with-param name="codes">abcdfgklmnopqrstvxyz</xsl:with-param>
503                         <xsl:with-param name="subdivCodes">vxyz</xsl:with-param>
504                         <xsl:with-param name="subdivDelimiter">-- </xsl:with-param>
505                     </xsl:call-template>
506                 </xsl:with-param>
507             </xsl:call-template>
508             </a>
509             <xsl:choose>
510             <xsl:when test="position()=last()"></xsl:when>
511             <xsl:otherwise> | </xsl:otherwise>
512             </xsl:choose>
513
514             </xsl:for-each>
515             </span>
516         </xsl:if>
517
518 <!-- Image processing code added here, takes precedence over text links including y3z text   -->
519         <xsl:if test="marc:datafield[@tag=856]">
520         <span class="results_summary online_resources"><span class="label">Online Resources: </span>
521         <xsl:for-each select="marc:datafield[@tag=856]">
522             <xsl:variable name="SubqText"><xsl:value-of select="marc:subfield[@code='q']"/></xsl:variable>
523             <a><xsl:attribute name="href"><xsl:value-of select="marc:subfield[@code='u']"/></xsl:attribute>
524             <xsl:if test="$OPACURLOpenInNewWindow='1'">
525                 <xsl:attribute name="target">_blank</xsl:attribute>
526             </xsl:if>
527             <xsl:choose>
528             <xsl:when test="($Show856uAsImage='Details' or $Show856uAsImage='Both') and (substring($SubqText,1,6)='image/' or $SubqText='img' or $SubqText='bmp' or $SubqText='cod' or $SubqText='gif' or $SubqText='ief' or $SubqText='jpe' or $SubqText='jpeg' or $SubqText='jpg' or $SubqText='jfif' or $SubqText='png' or $SubqText='svg' or $SubqText='tif' or $SubqText='tiff' or $SubqText='ras' or $SubqText='cmx' or $SubqText='ico' or $SubqText='pnm' or $SubqText='pbm' or $SubqText='pgm' or $SubqText='ppm' or $SubqText='rgb' or $SubqText='xbm' or $SubqText='xpm' or $SubqText='xwd')">
529                 <xsl:element name="img"><xsl:attribute name="src"><xsl:value-of select="marc:subfield[@code='u']"/></xsl:attribute><xsl:attribute name="alt"><xsl:value-of select="marc:subfield[@code='y']"/></xsl:attribute><xsl:attribute name="height">100</xsl:attribute></xsl:element><xsl:text></xsl:text>
530             </xsl:when>                                    
531             <xsl:when test="marc:subfield[@code='y' or @code='3' or @code='z']">
532                 <xsl:call-template name="subfieldSelect">
533                     <xsl:with-param name="codes">y3z</xsl:with-param>
534                 </xsl:call-template>
535             </xsl:when>
536             <xsl:when test="$URLLinkText!=''">
537                 <xsl:value-of select="$URLLinkText"/>
538             </xsl:when>
539             <xsl:otherwise>
540                 <xsl:text>Click here to access online</xsl:text>
541             </xsl:otherwise>
542             </xsl:choose>
543             </a>
544             <xsl:choose>
545             <xsl:when test="position()=last()"><xsl:text>  </xsl:text></xsl:when>
546             <xsl:otherwise> | </xsl:otherwise>
547             </xsl:choose>
548         </xsl:for-each>
549         </span>
550         </xsl:if>
551
552         <!-- 530 -->
553         <xsl:if test="marc:datafield[@tag=530]">
554         <xsl:for-each select="marc:datafield[@tag=530]">
555         <span class="results_summary additionalforms">
556             <xsl:call-template name="subfieldSelect">
557                 <xsl:with-param name="codes">abcd</xsl:with-param>
558             </xsl:call-template>
559             <xsl:for-each select="marc:subfield[@code='u']">
560                 <a><xsl:attribute name="href"><xsl:value-of select="text()"/></xsl:attribute>
561                 <xsl:if test="$OPACURLOpenInNewWindow='1'">
562                     <xsl:attribute name="target">_blank</xsl:attribute>
563                 </xsl:if>
564                 <xsl:value-of select="text()"/>
565                 </a>
566             </xsl:for-each>
567         </span>
568         </xsl:for-each>
569         </xsl:if>
570
571         <!-- 505 -->
572         <xsl:if test="marc:datafield[@tag=505]">
573         <xsl:for-each select="marc:datafield[@tag=505]">
574         <span class="results_summary contents">
575         <xsl:choose>
576         <xsl:when test="@ind1=1">
577             <span class="label">Incomplete contents:</span>
578         </xsl:when>
579         <xsl:when test="@ind1=1">
580             <span class="label">Partial contents:</span>
581         </xsl:when>
582         <xsl:otherwise>
583             <span class="label">Contents:</span>
584         </xsl:otherwise>
585         </xsl:choose>
586         <xsl:choose>
587         <xsl:when test="@ind2=0">
588             <xsl:call-template name="subfieldSelect">
589                 <xsl:with-param name="codes">tru</xsl:with-param>
590             </xsl:call-template>
591         </xsl:when>
592         <xsl:otherwise>
593             <xsl:call-template name="subfieldSelect">
594                 <xsl:with-param name="codes">au</xsl:with-param>
595             </xsl:call-template>
596         </xsl:otherwise>
597         </xsl:choose>
598         </span>
599         </xsl:for-each>
600         </xsl:if>
601
602         <!-- 583 -->
603         <xsl:if test="marc:datafield[@tag=583]">
604         <xsl:for-each select="marc:datafield[@tag=583]">
605             <xsl:if test="@ind1=1 or @ind1=' '">
606             <span class="results_summary actionnote">
607                 <xsl:choose>
608                 <xsl:when test="marc:subfield[@code='z']">
609                     <xsl:value-of select="marc:subfield[@code='z']"/>
610                 </xsl:when>
611                 <xsl:otherwise>
612                     <xsl:call-template name="subfieldSelect">
613                         <xsl:with-param name="codes">abcdefgijklnou</xsl:with-param>
614                     </xsl:call-template>
615                 </xsl:otherwise>
616                 </xsl:choose>
617             </span>
618             </xsl:if>
619         </xsl:for-each>
620         </xsl:if>
621
622         <!-- 586 -->
623         <xsl:if test="marc:datafield[@tag=586]">
624         <xsl:for-each select="marc:datafield[@tag=586]">
625             <span class="results_summary awardsnote">
626                 <xsl:if test="@ind1=' '">
627                 <span class="label">Awards: </span>
628                 </xsl:if>
629                 <xsl:value-of select="marc:subfield[@code='a']"/>
630             </span>
631         </xsl:for-each>
632         </xsl:if>
633
634         <!-- 773 -->
635         <xsl:if test="marc:datafield[@tag=773]">
636         <xsl:for-each select="marc:datafield[@tag=773]">
637         <xsl:if test="@ind1=0">
638         <span class="results_summary in"><span class="label">
639         <xsl:choose>
640         <xsl:when test="@ind2=' '">
641             In:
642         </xsl:when>
643         <xsl:when test="@ind2=8">
644             <xsl:if test="marc:subfield[@code='i']">
645                 <xsl:value-of select="marc:subfield[@code='i']"/>
646             </xsl:if>
647         </xsl:when>
648         </xsl:choose>
649         </span>
650                 <xsl:variable name="f773">
651                     <xsl:call-template name="chopPunctuation"><xsl:with-param name="chopString"><xsl:call-template name="subfieldSelect">
652                         <xsl:with-param name="codes">a_t</xsl:with-param>
653                     </xsl:call-template></xsl:with-param></xsl:call-template>
654                 </xsl:variable>
655             <xsl:choose>
656                 <xsl:when test="$UseControlNumber = '1' and marc:subfield[@code='w']">
657                     <a><xsl:attribute name="href">/cgi-bin/koha/opac-search.pl?q=Control-number:<xsl:call-template name="extractControlNumber"><xsl:with-param name="subfieldW" select="marc:subfield[@code='w']"/></xsl:call-template></xsl:attribute>
658                         <xsl:value-of select="translate($f773, '()', '')"/>
659                     </a>
660                     <xsl:if test="marc:subfield[@code='g']"><xsl:text> </xsl:text><xsl:value-of select="marc:subfield[@code='g']"/></xsl:if>
661                 </xsl:when>
662                 <xsl:when test="marc:subfield[@code='0']">
663                     <a><xsl:attribute name="href">/cgi-bin/koha/opac-detail.pl?biblionumber=<xsl:value-of select="marc:subfield[@code='0']"/></xsl:attribute>
664                         <xsl:value-of select="$f773"/>
665                     </a>
666                 </xsl:when>
667                 <xsl:otherwise>
668                     <a><xsl:attribute name="href">/cgi-bin/koha/opac-search.pl?q=ti,phr:<xsl:value-of select="translate($f773, '()', '')"/></xsl:attribute>
669                         <xsl:value-of select="$f773"/>
670                     </a>
671                     <xsl:if test="marc:subfield[@code='g']"><xsl:text> </xsl:text><xsl:value-of select="marc:subfield[@code='g']"/></xsl:if>
672                 </xsl:otherwise>
673             </xsl:choose>
674         </span>
675
676         <xsl:if test="marc:subfield[@code='n']">
677             <span class="results_summary"><xsl:value-of select="marc:subfield[@code='n']"/></span>
678         </xsl:if>
679
680         </xsl:if>
681         </xsl:for-each>
682         </xsl:if>
683
684         <xsl:for-each select="marc:datafield[@tag=520]">
685         <span class="results_summary summary"><span class="label">
686         <xsl:choose>
687           <xsl:when test="@ind1=0"><xsl:text>Subject: </xsl:text></xsl:when>
688           <xsl:when test="@ind1=1"><xsl:text>Review: </xsl:text></xsl:when>
689           <xsl:when test="@ind1=2"><xsl:text>Scope and content: </xsl:text></xsl:when>
690           <xsl:when test="@ind1=3"><xsl:text>Abstract: </xsl:text></xsl:when>
691           <xsl:when test="@ind1=4"><xsl:text>Content advice: </xsl:text></xsl:when>
692           <xsl:otherwise><xsl:text>Summary: </xsl:text></xsl:otherwise>
693         </xsl:choose>
694         </span>
695         <xsl:call-template name="subfieldSelect">
696           <xsl:with-param name="codes">abcu</xsl:with-param>
697         </xsl:call-template>
698         </span>
699         </xsl:for-each>
700
701         <!-- 866 textual holdings -->
702         <xsl:if test="marc:datafield[@tag=866]">
703             <span class="results_summary holdings_note"><span class="label">Holdings Note: </span>
704                 <xsl:for-each select="marc:datafield[@tag=866]">
705                     <xsl:call-template name="subfieldSelect">
706                         <xsl:with-param name="codes">az</xsl:with-param>
707                     </xsl:call-template>
708                     <xsl:choose><xsl:when test="position()=last()"><xsl:text></xsl:text></xsl:when><xsl:otherwise><xsl:text>; </xsl:text></xsl:otherwise></xsl:choose>
709                 </xsl:for-each>
710             </span>
711         </xsl:if>
712
713         <!--  775 Other Edition  -->
714         <xsl:if test="marc:datafield[@tag=775]">
715         <span class="results_summary other_editions"><span class="label">Other Editions: </span>
716         <xsl:for-each select="marc:datafield[@tag=775]">
717             <xsl:if test="marc:subfield[@code='i']">
718                 <xsl:call-template name="subfieldSelect">
719                     <xsl:with-param name="codes">i</xsl:with-param>
720                 </xsl:call-template>
721                 <xsl:text>: </xsl:text>
722             </xsl:if>
723             <a>
724             <xsl:choose>
725             <xsl:when test="$UseControlNumber = '1' and marc:subfield[@code='w']">
726                 <xsl:attribute name="href">/cgi-bin/koha/opac-search.pl?q=Control-number:<xsl:call-template name="extractControlNumber"><xsl:with-param name="subfieldW" select="marc:subfield[@code='w']"/></xsl:call-template></xsl:attribute>
727             </xsl:when>
728             <xsl:otherwise>
729                 <xsl:attribute name="href">/cgi-bin/koha/opac-search.pl?q=ti,phr:<xsl:value-of select="translate(marc:subfield[@code='t'], '.', '')"/></xsl:attribute>
730             </xsl:otherwise>
731             </xsl:choose>
732             <xsl:call-template name="subfieldSelect">
733                 <xsl:with-param name="codes">t</xsl:with-param>
734             </xsl:call-template>
735             </a>
736             <xsl:choose>
737                 <xsl:when test="position()=last()"></xsl:when>
738                 <xsl:otherwise><xsl:text>; </xsl:text></xsl:otherwise>
739             </xsl:choose>
740         </xsl:for-each>
741         </span>
742         </xsl:if>
743
744         <!-- 780 -->
745         <xsl:if test="marc:datafield[@tag=780]">
746         <xsl:for-each select="marc:datafield[@tag=780]">
747         <xsl:if test="@ind1=0">
748         <span class="results_summary preceeding_entry">
749         <xsl:choose>
750         <xsl:when test="@ind2=0">
751             <span class="label">Continues:</span>
752         </xsl:when>
753         <xsl:when test="@ind2=1">
754             <span class="label">Continues in part:</span>
755         </xsl:when>
756         <xsl:when test="@ind2=2">
757             <span class="label">Supersedes:</span>
758         </xsl:when>
759         <xsl:when test="@ind2=3">
760             <span class="label">Supersedes in part:</span>
761         </xsl:when>
762         <xsl:when test="@ind2=4">
763             <span class="label">Formed by the union: ... and: ...</span>
764         </xsl:when>
765         <xsl:when test="@ind2=5">
766             <span class="label">Absorbed:</span>
767         </xsl:when>
768         <xsl:when test="@ind2=6">
769             <span class="label">Absorbed in part:</span>
770         </xsl:when>
771         <xsl:when test="@ind2=7">
772             <span class="label">Separated from:</span>
773         </xsl:when>
774         </xsl:choose>
775                 <xsl:variable name="f780">
776                     <xsl:call-template name="subfieldSelect">
777                         <xsl:with-param name="codes">a_t</xsl:with-param>
778                     </xsl:call-template>
779                 </xsl:variable>
780             <xsl:choose>
781                 <xsl:when test="$UseControlNumber = '1' and marc:subfield[@code='w']">
782                     <a><xsl:attribute name="href">/cgi-bin/koha/opac-search.pl?q=Control-number:<xsl:call-template name="extractControlNumber"><xsl:with-param name="subfieldW" select="marc:subfield[@code='w']"/></xsl:call-template></xsl:attribute>
783                         <xsl:value-of select="translate($f780, '()', '')"/>
784                     </a>
785                 </xsl:when>
786                 <xsl:otherwise>
787                     <a><xsl:attribute name="href">/cgi-bin/koha/opac-search.pl?q=<xsl:value-of select="translate($f780, '()', '')"/></xsl:attribute>
788                         <xsl:value-of select="translate($f780, '()', '')"/>
789                     </a>
790                 </xsl:otherwise>
791             </xsl:choose>
792         </span>
793
794         <xsl:if test="marc:subfield[@code='n']">
795             <span class="results_summary"><xsl:value-of select="marc:subfield[@code='n']"/></span>
796         </xsl:if>
797
798         </xsl:if>
799         </xsl:for-each>
800         </xsl:if>
801
802         <!-- 785 -->
803         <xsl:if test="marc:datafield[@tag=785]">
804         <xsl:for-each select="marc:datafield[@tag=785]">
805         <xsl:if test="@ind1=0">
806         <span class="results_summary succeeding_entry">
807         <xsl:choose>
808         <xsl:when test="@ind2=0">
809             <span class="label">Continued by:</span>
810         </xsl:when>
811         <xsl:when test="@ind2=1">
812             <span class="label">Continued in part by:</span>
813         </xsl:when>
814         <xsl:when test="@ind2=2">
815             <span class="label">Superseded by:</span>
816         </xsl:when>
817         <xsl:when test="@ind2=3">
818             <span class="label">Superseded in part by:</span>
819         </xsl:when>
820         <xsl:when test="@ind2=4">
821             <span class="label">Absorbed by:</span>
822         </xsl:when>
823         <xsl:when test="@ind2=5">
824             <span class="label">Absorbed in part by:</span>
825         </xsl:when>
826         <xsl:when test="@ind2=6">
827             <span class="label">Split into .. and ...:</span>
828         </xsl:when>
829         <xsl:when test="@ind2=7">
830             <span class="label">Merged with ... to form ...</span>
831         </xsl:when>
832         <xsl:when test="@ind2=8">
833             <span class="label">Changed back to:</span>
834         </xsl:when>
835
836         </xsl:choose>
837                    <xsl:variable name="f785">
838                     <xsl:call-template name="subfieldSelect">
839                         <xsl:with-param name="codes">a_t</xsl:with-param>
840                     </xsl:call-template>
841                 </xsl:variable>
842
843             <xsl:choose>
844                 <xsl:when test="$UseControlNumber = '1' and marc:subfield[@code='w']">
845                     <a><xsl:attribute name="href">/cgi-bin/koha/opac-search.pl?q=Control-number:<xsl:call-template name="extractControlNumber"><xsl:with-param name="subfieldW" select="marc:subfield[@code='w']"/></xsl:call-template></xsl:attribute>
846                         <xsl:value-of select="translate($f785, '()', '')"/>
847                     </a>
848                 </xsl:when>
849                 <xsl:otherwise>
850                     <a><xsl:attribute name="href">/cgi-bin/koha/opac-search.pl?q=<xsl:value-of select="translate($f785, '()', '')"/></xsl:attribute>
851                         <xsl:value-of select="translate($f785, '()', '')"/>
852                     </a>
853                 </xsl:otherwise>
854             </xsl:choose>
855
856         </span>
857
858         <xsl:if test="marc:subfield[@code='n']">
859             <span class="results_summary"><xsl:value-of select="marc:subfield[@code='n']"/></span>
860         </xsl:if>
861
862         </xsl:if>
863         </xsl:for-each>
864         </xsl:if>
865
866     </xsl:template>
867
868     <xsl:template name="showAuthor">
869         <xsl:param name="authorfield" />
870         <xsl:param name="UseAuthoritiesForTracings" />
871         <xsl:for-each select="$authorfield">
872             <xsl:choose><xsl:when test="position()!=1"><xsl:text>; </xsl:text></xsl:when></xsl:choose>
873             <xsl:choose>
874                 <xsl:when test="not(@tag=111 or @tag=711)" />
875                 <xsl:when test="marc:subfield[@code='n']">
876                     <xsl:text> </xsl:text>
877                     <xsl:call-template name="subfieldSelect">
878                         <xsl:with-param name="codes">n</xsl:with-param>
879                     </xsl:call-template>
880                     <xsl:text> </xsl:text>
881                 </xsl:when>
882             </xsl:choose>
883             <a>
884                 <xsl:choose>
885                     <xsl:when test="marc:subfield[@code=9] and $UseAuthoritiesForTracings='1'">
886                         <xsl:attribute name="href">/cgi-bin/koha/opac-search.pl?q=an:<xsl:value-of select="marc:subfield[@code=9]"/></xsl:attribute>
887                     </xsl:when>
888                     <xsl:otherwise>
889                         <xsl:attribute name="href">/cgi-bin/koha/opac-search.pl?q=au:<xsl:value-of select="marc:subfield[@code='a']"/></xsl:attribute>
890                     </xsl:otherwise>
891                 </xsl:choose>
892                 <xsl:choose>
893                     <xsl:when test="@tag=100 or @tag=700"><xsl:call-template name="nameABCDQ"/></xsl:when>
894                     <xsl:when test="@tag=110 or @tag=710"><xsl:call-template name="nameABCDN"/></xsl:when>
895                     <xsl:when test="@tag=111 or @tag=711"><xsl:call-template name="nameACDEQ"/></xsl:when>
896                 </xsl:choose>
897                 <!-- add relator code too between brackets-->
898                 <xsl:if test="marc:subfield[@code='4' or @code='e']">
899                     <xsl:text>[</xsl:text>
900                     <xsl:choose>
901                         <xsl:when test="marc:subfield[@code=4]"><xsl:value-of select="marc:subfield[@code=4]"/></xsl:when>
902                         <xsl:otherwise><xsl:value-of select="marc:subfield[@code='e']"/></xsl:otherwise>
903                     </xsl:choose>
904                     <xsl:text>]</xsl:text>
905                 </xsl:if>
906             </a>
907         </xsl:for-each>
908         <xsl:text>.</xsl:text>
909     </xsl:template>
910
911     <xsl:template name="nameABCDQ">
912             <xsl:call-template name="chopPunctuation">
913                 <xsl:with-param name="chopString">
914                     <xsl:call-template name="subfieldSelect">
915                         <xsl:with-param name="codes">aq</xsl:with-param>
916                     </xsl:call-template>
917                 </xsl:with-param>
918                 <xsl:with-param name="punctuation">
919                     <xsl:text>:,;/ </xsl:text>
920                 </xsl:with-param>
921             </xsl:call-template>
922         <xsl:call-template name="termsOfAddress"/>
923     </xsl:template>
924
925     <xsl:template name="nameABCDN">
926         <xsl:for-each select="marc:subfield[@code='a']">
927                 <xsl:call-template name="chopPunctuation">
928                     <xsl:with-param name="chopString" select="."/>
929                 </xsl:call-template>
930         </xsl:for-each>
931         <xsl:for-each select="marc:subfield[@code='b']">
932             <xsl:value-of select="."/>
933             <xsl:choose>
934                 <xsl:when test="position() != last()">
935                     <xsl:text> -- </xsl:text>
936                 </xsl:when>
937             </xsl:choose>
938         </xsl:for-each>
939         <xsl:if test="marc:subfield[@code='c'] or marc:subfield[@code='d'] or marc:subfield[@code='n']">
940                 <xsl:call-template name="subfieldSelect">
941                     <xsl:with-param name="codes">cdn</xsl:with-param>
942                 </xsl:call-template>
943         </xsl:if>
944     </xsl:template>
945
946     <xsl:template name="nameACDEQ">
947             <xsl:call-template name="subfieldSelect">
948                 <xsl:with-param name="codes">acdeq</xsl:with-param>
949             </xsl:call-template>
950     </xsl:template>
951     <xsl:template name="termsOfAddress">
952         <xsl:if test="marc:subfield[@code='b' or @code='c']">
953             <xsl:call-template name="chopPunctuation">
954                 <xsl:with-param name="chopString">
955                     <xsl:call-template name="subfieldSelect">
956                         <xsl:with-param name="codes">bc</xsl:with-param>
957                     </xsl:call-template>
958                 </xsl:with-param>
959             </xsl:call-template>
960         </xsl:if>
961     </xsl:template>
962
963     <xsl:template name="part">
964         <xsl:variable name="partNumber">
965             <xsl:call-template name="specialSubfieldSelect">
966                 <xsl:with-param name="axis">n</xsl:with-param>
967                 <xsl:with-param name="anyCodes">n</xsl:with-param>
968                 <xsl:with-param name="afterCodes">fghkdlmor</xsl:with-param>
969             </xsl:call-template>
970         </xsl:variable>
971         <xsl:variable name="partName">
972             <xsl:call-template name="specialSubfieldSelect">
973                 <xsl:with-param name="axis">p</xsl:with-param>
974                 <xsl:with-param name="anyCodes">p</xsl:with-param>
975                 <xsl:with-param name="afterCodes">fghkdlmor</xsl:with-param>
976             </xsl:call-template>
977         </xsl:variable>
978         <xsl:if test="string-length(normalize-space($partNumber))">
979                 <xsl:call-template name="chopPunctuation">
980                     <xsl:with-param name="chopString" select="$partNumber"/>
981                 </xsl:call-template>
982         </xsl:if>
983         <xsl:if test="string-length(normalize-space($partName))">
984                 <xsl:call-template name="chopPunctuation">
985                     <xsl:with-param name="chopString" select="$partName"/>
986                 </xsl:call-template>
987         </xsl:if>
988     </xsl:template>
989
990     <xsl:template name="specialSubfieldSelect">
991         <xsl:param name="anyCodes"/>
992         <xsl:param name="axis"/>
993         <xsl:param name="beforeCodes"/>
994         <xsl:param name="afterCodes"/>
995         <xsl:variable name="str">
996             <xsl:for-each select="marc:subfield">
997                 <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])">
998                     <xsl:value-of select="text()"/>
999                     <xsl:text> </xsl:text>
1000                 </xsl:if>
1001             </xsl:for-each>
1002         </xsl:variable>
1003         <xsl:value-of select="substring($str,1,string-length($str)-1)"/>
1004     </xsl:template>
1005 </xsl:stylesheet>