Bug 3228: Fix for Type: label in XSLT displays.
[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 <xsl:stylesheet version="1.0"
4   xmlns:marc="http://www.loc.gov/MARC21/slim"
5   xmlns:items="http://www.koha.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         <xsl:variable name="leader" select="marc:leader"/>
16         <xsl:variable name="leader6" select="substring($leader,7,1)"/>
17         <xsl:variable name="leader7" select="substring($leader,8,1)"/>
18         <xsl:variable name="controlField008" select="marc:controlfield[@tag=008]"/>
19         <xsl:variable name="materialTypeCode">
20             <xsl:choose>
21                 <xsl:when test="$leader6='a'">
22                     <xsl:choose>
23                         <xsl:when test="$leader7='a' or $leader7='c' or $leader7='d' or $leader7='m'">BK</xsl:when>
24                         <xsl:when test="$leader7='b' or $leader7='i' or $leader7='s'">SE</xsl:when>
25                     </xsl:choose>
26                 </xsl:when>
27                 <xsl:when test="$leader6='t'">BK</xsl:when>
28                 <xsl:when test="$leader6='p'">MX</xsl:when>
29                 <xsl:when test="$leader6='m'">CF</xsl:when>
30                 <xsl:when test="$leader6='e' or $leader6='f'">MP</xsl:when>
31                 <xsl:when test="$leader6='g' or $leader6='k' or $leader6='o' or $leader6='r'">VM</xsl:when>
32                 <xsl:when test="$leader6='c' or $leader6='d' or $leader6='i' or $leader6='j'">MU</xsl:when>
33             </xsl:choose>
34         </xsl:variable>
35         <xsl:variable name="materialTypeLabel">
36             <xsl:choose>
37                 <xsl:when test="$leader6='a'">
38                     <xsl:choose>
39                         <xsl:when test="$leader7='a' or $leader7='c' or $leader7='d' or $leader7='m'">Book</xsl:when>
40                         <xsl:when test="$leader7='b' or $leader7='i' or $leader7='s'">Continuing Resource</xsl:when>
41                     </xsl:choose>
42                 </xsl:when>
43                 <xsl:when test="$leader6='t'">Book</xsl:when>
44                 <xsl:when test="$leader6='p'">Mixed Materials</xsl:when>
45                 <xsl:when test="$leader6='m'">Computer File</xsl:when>
46                 <xsl:when test="$leader6='e' or $leader6='f'">Map</xsl:when>
47                 <xsl:when test="$leader6='g' or $leader6='k' or $leader6='o' or $leader6='r'">Visual Material</xsl:when>
48                 <xsl:when test="$leader6='c' or $leader6='d' or $leader6='i' or $leader6='j'">Sound</xsl:when>
49             </xsl:choose>
50         </xsl:variable>
51
52         <!-- Title Statement -->
53         <xsl:if test="marc:datafield[@tag=245]">
54         <h1>
55             <xsl:for-each select="marc:datafield[@tag=245]">
56                     <xsl:call-template name="subfieldSelect">
57                         <xsl:with-param name="codes">a</xsl:with-param>
58                     </xsl:call-template>
59                     <xsl:if test="marc:subfield[@code='b']">
60                         <xsl:text> </xsl:text>
61                         <xsl:call-template name="subfieldSelect">
62                             <xsl:with-param name="codes">b</xsl:with-param>
63                         </xsl:call-template>
64                     </xsl:if>
65                     <xsl:if test="marc:subfield[@code='h']">
66                         <xsl:text> </xsl:text>
67                         <xsl:call-template name="subfieldSelect">
68                             <xsl:with-param name="codes">h</xsl:with-param>
69                         </xsl:call-template>
70                     </xsl:if>
71                     <xsl:call-template name="subfieldSelect">
72                         <xsl:with-param name="codes">fgknps</xsl:with-param>
73                     </xsl:call-template>
74             </xsl:for-each>
75         </h1>
76         </xsl:if>
77
78         <xsl:choose>
79         <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]">
80         <h5 class="author">by
81         <xsl:for-each select="marc:datafield[@tag=100 or @tag=700]">
82         <a>
83         <xsl:choose>
84             <xsl:when test="marc:subfield[@code=9]">
85                 <xsl:attribute name="href">/cgi-bin/koha/opac-search.pl?q=an:<xsl:value-of select="marc:subfield[@code=9]"/></xsl:attribute>
86             </xsl:when>
87             <xsl:otherwise>
88             <xsl:attribute name="href">/cgi-bin/koha/opac-search.pl?q=au:<xsl:value-of select="marc:subfield[@code='a']"/></xsl:attribute>
89             </xsl:otherwise>
90         </xsl:choose>
91         <xsl:call-template name="nameABCDQ"/></a>
92         <xsl:choose>
93         <xsl:when test="position()=last()"><xsl:text>.</xsl:text></xsl:when><xsl:otherwise><xsl:text>; </xsl:text></xsl:otherwise></xsl:choose>
94         </xsl:for-each>
95
96         <xsl:for-each select="marc:datafield[@tag=110 or @tag=710]">
97         <a>
98         <xsl:choose>
99             <xsl:when test="marc:subfield[@code=9]">
100                 <xsl:attribute name="href">/cgi-bin/koha/opac-search.pl?q=an:<xsl:value-of select="marc:subfield[@code=9]"/></xsl:attribute>
101             </xsl:when>
102             <xsl:otherwise>
103             <xsl:attribute name="href">/cgi-bin/koha/opac-search.pl?q=au:<xsl:value-of select="marc:subfield[@code='a']"/></xsl:attribute>      
104             </xsl:otherwise>
105         </xsl:choose>
106         <xsl:call-template name="nameABCDN"/></a>
107         <xsl:choose><xsl:when test="position()=last()"><xsl:text>.</xsl:text></xsl:when><xsl:otherwise><xsl:text>; </xsl:text></xsl:otherwise></xsl:choose>
108         </xsl:for-each>
109
110         <xsl:for-each select="marc:datafield[@tag=111 or @tag=711]">
111         <a>
112         <xsl:choose>
113             <xsl:when test="marc:subfield[@code=9]">
114                 <xsl:attribute name="href">/cgi-bin/koha/opac-search.pl?q=an:<xsl:value-of select="marc:subfield[@code=9]"/></xsl:attribute>
115             </xsl:when>
116             <xsl:otherwise>
117             <xsl:attribute name="href">/cgi-bin/koha/opac-search.pl?q=au:<xsl:value-of select="marc:subfield[@code='a']"/></xsl:attribute>
118             </xsl:otherwise>
119         </xsl:choose>
120         <xsl:call-template name="nameACDEQ"/></a>
121         <xsl:choose><xsl:when test="position()=last()"><xsl:text>.</xsl:text></xsl:when><xsl:otherwise><xsl:text>; </xsl:text></xsl:otherwise></xsl:choose>
122
123         </xsl:for-each>
124         </h5>
125         </xsl:when>
126         </xsl:choose>
127         <div id="views">
128         <span class="view"><span id="Normalview">Normal View</span> </span>
129         <span class="view"><a id="MARCviewPop" href="/cgi-bin/koha/opac-showmarc.pl?id={marc:datafield[@tag=999]/marc:subfield[@code='c']}" title="MARC" rel="gb_page_center[600,500]">MARC View</a></span>
130         <span class="view"><a id="MARCview" href="/cgi-bin/koha/opac-MARCdetail.pl?biblionumber={marc:datafield[@tag=999]/marc:subfield[@code='c']}" title="MARC">Expanded MARC View</a></span>
131         <span class="view"><a id="ISBDview" href="/cgi-bin/koha/opac-ISBDdetail.pl?biblionumber={marc:datafield[@tag=999]/marc:subfield[@code='c']}">Card View (ISBD)</a></span>
132         </div> 
133
134
135         <xsl:if test="$materialTypeCode!=''">
136         <span class="results_summary"><span class="label">Type: </span>
137         <xsl:element name="img"><xsl:attribute name="src">/opac-tmpl/prog/famfamfam/<xsl:value-of select="$materialTypeCode"/>.png</xsl:attribute><xsl:attribute name="alt"></xsl:attribute></xsl:element>
138         <xsl:value-of select="$materialTypeLabel"/>
139         </span>
140         </xsl:if>
141         <xsl:if test="marc:datafield[@tag=440 or @tag=490]">
142         <span class="results_summary"><span class="label">Series: </span>
143         <xsl:for-each select="marc:datafield[@tag=440]">
144              <a href="/cgi-bin/koha/opac-search.pl?q=se:{marc:subfield[@code='a']}">
145             <xsl:call-template name="chopPunctuation">
146                             <xsl:with-param name="chopString">
147                                 <xsl:call-template name="subfieldSelect">
148                                     <xsl:with-param name="codes">av</xsl:with-param>
149                                 </xsl:call-template>
150                             </xsl:with-param>
151                         </xsl:call-template>
152                         </a>
153                     <xsl:text> </xsl:text><xsl:call-template name="part"/>
154             <xsl:choose><xsl:when test="position()=last()"><xsl:text>.</xsl:text></xsl:when><xsl:otherwise><xsl:text>; </xsl:text></xsl:otherwise></xsl:choose>
155         </xsl:for-each>
156
157         <xsl:for-each select="marc:datafield[@tag=490][@ind1=0]">
158              <a href="/cgi-bin/koha/opac-search.pl?q=se:{marc:subfield[@code='a']}">
159                         <xsl:call-template name="chopPunctuation">
160                             <xsl:with-param name="chopString">
161                                 <xsl:call-template name="subfieldSelect">
162                                     <xsl:with-param name="codes">av</xsl:with-param>
163                                 </xsl:call-template>
164                             </xsl:with-param>
165                         </xsl:call-template>
166             </a>
167                     <xsl:call-template name="part"/>
168         <xsl:choose><xsl:when test="position()=last()"><xsl:text>.</xsl:text></xsl:when><xsl:otherwise><xsl:text>; </xsl:text></xsl:otherwise></xsl:choose>
169         </xsl:for-each>
170         </span>
171         </xsl:if>
172         <xsl:if test="marc:datafield[@tag=260]">
173         <span class="results_summary"><span class="label">Publisher: </span>
174             <xsl:for-each select="marc:datafield[@tag=260]">
175                 <xsl:call-template name="chopPunctuation">
176                   <xsl:with-param name="chopString">
177                     <xsl:call-template name="subfieldSelect">
178                         <xsl:with-param name="codes">bcg</xsl:with-param>
179                     </xsl:call-template>
180                    </xsl:with-param>
181                </xsl:call-template>
182                     <xsl:choose><xsl:when test="position()=last()"><xsl:text>.</xsl:text></xsl:when><xsl:otherwise><xsl:text>; </xsl:text></xsl:otherwise></xsl:choose>
183             </xsl:for-each>
184         </span> 
185         </xsl:if>
186         <xsl:if test="marc:datafield[@tag=250]">
187         <span class="results_summary"><span class="label">Edition: </span>
188             <xsl:for-each select="marc:datafield[@tag=250]">
189                 <xsl:call-template name="chopPunctuation">
190                   <xsl:with-param name="chopString">
191                     <xsl:call-template name="subfieldSelect">
192                         <xsl:with-param name="codes">ab</xsl:with-param>
193                     </xsl:call-template>
194                    </xsl:with-param>
195                </xsl:call-template>
196                     <xsl:choose><xsl:when test="position()=last()"><xsl:text>.</xsl:text></xsl:when><xsl:otherwise><xsl:text>; </xsl:text></xsl:otherwise></xsl:choose>
197             </xsl:for-each>
198         </span>
199         </xsl:if>
200
201         <xsl:if test="marc:datafield[@tag=300]">
202         <span class="results_summary"><span class="label">Description: </span>
203             <xsl:for-each select="marc:datafield[@tag=300]">
204                 <xsl:call-template name="chopPunctuation">
205                   <xsl:with-param name="chopString">
206                     <xsl:call-template name="subfieldSelect">
207                         <xsl:with-param name="codes">abceg</xsl:with-param>
208                     </xsl:call-template>
209                    </xsl:with-param>
210                </xsl:call-template>
211                     <xsl:choose><xsl:when test="position()=last()"><xsl:text>.</xsl:text></xsl:when><xsl:otherwise><xsl:text>; </xsl:text></xsl:otherwise></xsl:choose>
212             </xsl:for-each>
213         </span>
214        </xsl:if>
215
216        <abbr class="unapi-id" title="koha:biblionumber:{marc:datafield[@tag=999]/marc:subfield[@code='c']}" ><!-- unAPI --></abbr>
217
218        <xsl:if test="marc:datafield[@tag=020]">
219         <span class="results_summary"><span class="label">ISBN: </span>
220         <xsl:for-each select="marc:datafield[@tag=020]">
221         <xsl:variable name="isbn" select="marc:subfield[@code='a']"/>
222                 <xsl:value-of select="marc:subfield[@code='a']"/>
223                 <xsl:choose><xsl:when test="position()=last()"><xsl:text>.</xsl:text></xsl:when><xsl:otherwise><xsl:text>; </xsl:text></xsl:otherwise></xsl:choose>
224         </xsl:for-each>
225         </span>
226         </xsl:if>
227
228         <xsl:if test="marc:datafield[@tag=022]">
229         <span class="results_summary"><span class="label">ISSN: </span>
230         <xsl:for-each select="marc:datafield[@tag=022]">
231                 <xsl:value-of select="marc:subfield[@code='a']"/>
232                 <xsl:choose><xsl:when test="position()=last()"><xsl:text>.</xsl:text></xsl:when><xsl:otherwise><xsl:text>; </xsl:text></xsl:otherwise></xsl:choose>
233         </xsl:for-each>
234         </span>
235         </xsl:if>
236
237         <xsl:if test="marc:datafield[@tag=246]">
238         <span class="results_summary"><span class="label">Other Title: </span>
239             <xsl:for-each select="marc:datafield[@tag=246]">
240                 <xsl:call-template name="chopPunctuation">
241                   <xsl:with-param name="chopString">
242                     <xsl:call-template name="subfieldSelect">
243                         <xsl:with-param name="codes">iabhfgnp</xsl:with-param>
244                     </xsl:call-template>
245                    </xsl:with-param>
246                </xsl:call-template>
247                     <xsl:choose><xsl:when test="position()=last()"><xsl:text>.</xsl:text></xsl:when><xsl:otherwise><xsl:text>; </xsl:text></xsl:otherwise></xsl:choose>
248             </xsl:for-each>
249         </span>
250        </xsl:if>
251
252         <xsl:if test="marc:datafield[@tag=130]|marc:datafield[@tag=240]|marc:datafield[@tag=730][@ind2!=2]">
253         <span class="results_summary"><span class="label">Uniform titles: </span>
254         <xsl:for-each select="marc:datafield[@tag=130]|marc:datafield[@tag=240]|marc:datafield[@tag=730][@ind2!=2]">
255             <xsl:variable name="str">
256                 <xsl:for-each select="marc:subfield">
257                     <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'])))">
258                         <xsl:value-of select="text()"/>
259                         <xsl:text> </xsl:text>
260                      </xsl:if>
261                 </xsl:for-each>
262             </xsl:variable>
263             <xsl:call-template name="chopPunctuation">
264                 <xsl:with-param name="chopString">
265                     <xsl:value-of select="substring($str,1,string-length($str)-1)"/>
266                         
267                 </xsl:with-param>
268             </xsl:call-template>
269             <xsl:choose><xsl:when test="position()=last()"><xsl:text>.</xsl:text></xsl:when><xsl:otherwise><xsl:text>; </xsl:text></xsl:otherwise></xsl:choose>
270         </xsl:for-each>
271         </span>
272         </xsl:if>
273
274         <xsl:if test="marc:datafield[substring(@tag, 1, 1) = '6']">
275             <span class="results_summary"><span class="label">Related Subjects: </span>
276             <xsl:for-each select="marc:datafield[substring(@tag, 1, 1) = '6']">
277             <a>
278             <xsl:choose>
279             <xsl:when test="marc:subfield[@code=9]">
280                 <xsl:attribute name="href">/cgi-bin/koha/opac-search.pl?q=an:<xsl:value-of select="marc:subfield[@code=9]"/></xsl:attribute>
281             </xsl:when>
282             <xsl:otherwise>
283                 <xsl:attribute name="href">/cgi-bin/koha/opac-search.pl?q=su:<xsl:value-of select="marc:subfield[@code='a']"/></xsl:attribute>
284             </xsl:otherwise>
285             </xsl:choose>
286             <xsl:call-template name="chopPunctuation">
287                 <xsl:with-param name="chopString">
288                     <xsl:call-template name="subfieldSelect">
289                         <xsl:with-param name="codes">abcdvxyz</xsl:with-param>
290                         <xsl:with-param name="subdivCodes">vxyz</xsl:with-param>
291                         <xsl:with-param name="subdivDelimiter">-- </xsl:with-param>
292                     </xsl:call-template>
293                 </xsl:with-param>
294             </xsl:call-template>
295             </a>
296             <xsl:choose>
297             <xsl:when test="position()=last()"></xsl:when>
298             <xsl:otherwise> | </xsl:otherwise>
299             </xsl:choose>
300
301             </xsl:for-each>
302             </span>
303         </xsl:if>
304
305         <xsl:if test="marc:datafield[@tag=856]">
306         <span class="results_summary"><span class="label">Online Resources: </span>
307         <xsl:for-each select="marc:datafield[@tag=856]">
308             <a><xsl:attribute name="href"><xsl:value-of select="marc:subfield[@code='u']"/></xsl:attribute>
309         <xsl:choose>
310             <xsl:when test="marc:subfield[@code='y' or @code='3' or @code='z']">
311                     <xsl:call-template name="subfieldSelect">
312                         <xsl:with-param name="codes">y3z</xsl:with-param>
313                     </xsl:call-template>
314             </xsl:when>
315         <xsl:when test="not(marc:subfield[@code='y']) and not(marc:subfield[@code='3']) and not(marc:subfield[@code='z'])">
316         Click here to access online
317         </xsl:when>
318         </xsl:choose>
319         </a>
320             <xsl:choose>
321             <xsl:when test="position()=last()"></xsl:when>
322             <xsl:otherwise> | </xsl:otherwise>
323             </xsl:choose>
324             
325         </xsl:for-each>
326         </span>
327         </xsl:if>
328         <xsl:if test="marc:datafield[@tag=505]">
329         <xsl:for-each select="marc:datafield[@tag=505]">
330         <span class="results_summary"><span class="label">
331         <xsl:choose>
332         <xsl:when test="@ind1=0">
333             Contents:
334         </xsl:when>
335         <xsl:when test="@ind1=1">
336             Incomplete contents:
337         </xsl:when>
338         <xsl:when test="@ind1=1">
339             Partial contents:
340         </xsl:when>
341         </xsl:choose>  
342         </span>
343         <xsl:choose>
344         <xsl:when test="@ind2=0">
345             <xsl:for-each select="marc:subfield[@code='t']">
346                 <xsl:value-of select="marc:subfield[@code=t]"/> <xsl:value-of select="marc:subfield[@code=r]"/>
347             </xsl:for-each> 
348         </xsl:when>
349         <xsl:otherwise>
350             <xsl:call-template name="subfieldSelect">
351                 <xsl:with-param name="codes">au</xsl:with-param>
352             </xsl:call-template>
353         </xsl:otherwise>
354         </xsl:choose>
355         </span>
356         </xsl:for-each>
357         </xsl:if>
358
359         <!-- 780 -->
360         <xsl:if test="marc:datafield[@tag=780]">
361         <xsl:for-each select="marc:datafield[@tag=780]">
362         <span class="results_summary"><span class="label">
363         <xsl:choose>
364         <xsl:when test="@ind2=0">
365             Continues:
366         </xsl:when>
367         <xsl:when test="@ind2=1">
368             Continues in part:
369         </xsl:when>
370         <xsl:when test="@ind2=2">
371             Supersedes:
372         </xsl:when>
373         <xsl:when test="@ind2=3">
374             Supersedes in part:
375         </xsl:when>
376         <xsl:when test="@ind2=4">
377             Formed by the union: ... and: ...
378         </xsl:when>
379         <xsl:when test="@ind2=5">
380             Absorbed:
381         </xsl:when>
382         <xsl:when test="@ind2=6">
383             Absorbed in part:
384         </xsl:when>
385         <xsl:when test="@ind2=7">
386             Separated from:
387         </xsl:when>
388         </xsl:choose>
389         </span>
390                 <xsl:variable name="f780">
391                     <xsl:call-template name="subfieldSelect">
392                         <xsl:with-param name="codes">at</xsl:with-param>
393                     </xsl:call-template>
394                 </xsl:variable>
395              <a><xsl:attribute name="href">/cgi-bin/koha/opac-search.pl?q=<xsl:value-of select="translate($f780, '()', '')"/></xsl:attribute>
396                 <xsl:value-of select="translate($f780, '()', '')"/>
397             </a>
398         </span>
399  
400         <xsl:choose>
401         <xsl:when test="@ind1=0">
402             <span class="results_summary"><xsl:value-of select="marc:subfield[@code='n']"/></span>
403         </xsl:when>
404         </xsl:choose>
405
406         </xsl:for-each>
407         </xsl:if>
408
409         <!-- 785 -->
410         <xsl:if test="marc:datafield[@tag=785]">
411         <xsl:for-each select="marc:datafield[@tag=785]">
412         <span class="results_summary"><span class="label">
413         <xsl:choose>
414         <xsl:when test="@ind2=0">
415             Continued by:
416         </xsl:when>
417         <xsl:when test="@ind2=1">
418             Continued in part by:
419         </xsl:when>
420         <xsl:when test="@ind2=2">
421             Superseded by:
422         </xsl:when>
423         <xsl:when test="@ind2=3">
424             Superseded in part by:
425         </xsl:when>
426         <xsl:when test="@ind2=4">
427             Absorbed by:
428         </xsl:when>
429         <xsl:when test="@ind2=5">
430             Absorbed in part by:
431         </xsl:when>
432         <xsl:when test="@ind2=6">
433             Split into .. and ...:
434         </xsl:when>
435         <xsl:when test="@ind2=7">
436             Merged with ... to form ...
437         </xsl:when>
438         <xsl:when test="@ind2=8">
439             Changed back to:
440         </xsl:when>
441
442         </xsl:choose>
443         </span>
444                    <xsl:variable name="f785">
445                     <xsl:call-template name="subfieldSelect">
446                         <xsl:with-param name="codes">at</xsl:with-param>
447                     </xsl:call-template>
448                 </xsl:variable>
449
450                 <a><xsl:attribute name="href">/cgi-bin/koha/opac-search.pl?q=<xsl:value-of select="translate($f785, '()', '')"/></xsl:attribute>
451                 <xsl:value-of select="translate($f785, '()', '')"/>
452             </a>
453
454         </span>
455         </xsl:for-each>
456         </xsl:if>
457
458     </xsl:template>
459
460     <xsl:template name="nameABCDQ">
461             <xsl:call-template name="chopPunctuation">
462                 <xsl:with-param name="chopString">
463                     <xsl:call-template name="subfieldSelect">
464                         <xsl:with-param name="codes">aq</xsl:with-param>
465                     </xsl:call-template>
466                 </xsl:with-param>
467                 <xsl:with-param name="punctuation">
468                     <xsl:text>:,;/ </xsl:text>
469                 </xsl:with-param>
470             </xsl:call-template>
471         <xsl:call-template name="termsOfAddress"/>
472     </xsl:template>
473
474     <xsl:template name="nameABCDN">
475         <xsl:for-each select="marc:subfield[@code='a']">
476                 <xsl:call-template name="chopPunctuation">
477                     <xsl:with-param name="chopString" select="."/>
478                 </xsl:call-template>
479         </xsl:for-each>
480         <xsl:for-each select="marc:subfield[@code='b']">
481                 <xsl:value-of select="."/>
482         </xsl:for-each>
483         <xsl:if test="marc:subfield[@code='c'] or marc:subfield[@code='d'] or marc:subfield[@code='n']">
484                 <xsl:call-template name="subfieldSelect">
485                     <xsl:with-param name="codes">cdn</xsl:with-param>
486                 </xsl:call-template>
487         </xsl:if>
488     </xsl:template>
489
490     <xsl:template name="nameACDEQ">
491             <xsl:call-template name="subfieldSelect">
492                 <xsl:with-param name="codes">acdeq</xsl:with-param>
493             </xsl:call-template>
494     </xsl:template>
495     <xsl:template name="termsOfAddress">
496         <xsl:if test="marc:subfield[@code='b' or @code='c']">
497             <xsl:call-template name="chopPunctuation">
498                 <xsl:with-param name="chopString">
499                     <xsl:call-template name="subfieldSelect">
500                         <xsl:with-param name="codes">bc</xsl:with-param>
501                     </xsl:call-template>
502                 </xsl:with-param>
503             </xsl:call-template>
504         </xsl:if>
505     </xsl:template>
506
507     <xsl:template name="part">
508         <xsl:variable name="partNumber">
509             <xsl:call-template name="specialSubfieldSelect">
510                 <xsl:with-param name="axis">n</xsl:with-param>
511                 <xsl:with-param name="anyCodes">n</xsl:with-param>
512                 <xsl:with-param name="afterCodes">fghkdlmor</xsl:with-param>
513             </xsl:call-template>
514         </xsl:variable>
515         <xsl:variable name="partName">
516             <xsl:call-template name="specialSubfieldSelect">
517                 <xsl:with-param name="axis">p</xsl:with-param>
518                 <xsl:with-param name="anyCodes">p</xsl:with-param>
519                 <xsl:with-param name="afterCodes">fghkdlmor</xsl:with-param>
520             </xsl:call-template>
521         </xsl:variable>
522         <xsl:if test="string-length(normalize-space($partNumber))">
523                 <xsl:call-template name="chopPunctuation">
524                     <xsl:with-param name="chopString" select="$partNumber"/>
525                 </xsl:call-template>
526         </xsl:if>
527         <xsl:if test="string-length(normalize-space($partName))">
528                 <xsl:call-template name="chopPunctuation">
529                     <xsl:with-param name="chopString" select="$partName"/>
530                 </xsl:call-template>
531         </xsl:if>
532     </xsl:template>
533
534     <xsl:template name="specialSubfieldSelect">
535         <xsl:param name="anyCodes"/>
536         <xsl:param name="axis"/>
537         <xsl:param name="beforeCodes"/>
538         <xsl:param name="afterCodes"/>
539         <xsl:variable name="str">
540             <xsl:for-each select="marc:subfield">
541                 <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])">
542                     <xsl:value-of select="text()"/>
543                     <xsl:text> </xsl:text>
544                 </xsl:if>
545             </xsl:for-each>
546         </xsl:variable>
547         <xsl:value-of select="substring($str,1,string-length($str)-1)"/>
548     </xsl:template>
549 </xsl:stylesheet>