MT3421, Follow-up: Moves subscription history in a separate page
[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        <xsl:if test="marc:datafield[@tag=020]">
217         <span class="results_summary"><span class="label">ISBN: </span>
218         <!-- unAPI <abbr/> tag -->
219         <xsl:for-each select="marc:datafield[@tag=020]">
220         <xsl:variable name="isbn" select="marc:subfield[@code='a']"/>
221         <abbr class="unapi-id" title="koha:isbn:{$isbn}"><xsl:value-of select="marc:subfield[@code='a']"/></abbr>
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         </span>
225         </xsl:if>
226
227         <xsl:if test="marc:datafield[@tag=022]">
228         <span class="results_summary"><span class="label">ISSN: </span>
229         <xsl:for-each select="marc:datafield[@tag=022]">
230                 <xsl:value-of select="marc:subfield[@code='a']"/>
231                 <xsl:choose><xsl:when test="position()=last()"><xsl:text>.</xsl:text></xsl:when><xsl:otherwise><xsl:text>; </xsl:text></xsl:otherwise></xsl:choose>
232         </xsl:for-each>
233         </span>
234         </xsl:if>
235
236         <xsl:if test="marc:datafield[@tag=246]">
237         <span class="results_summary"><span class="label">Other Title: </span>
238             <xsl:for-each select="marc:datafield[@tag=246]">
239                 <xsl:call-template name="chopPunctuation">
240                   <xsl:with-param name="chopString">
241                     <xsl:call-template name="subfieldSelect">
242                         <xsl:with-param name="codes">iabhfgnp</xsl:with-param>
243                     </xsl:call-template>
244                    </xsl:with-param>
245                </xsl:call-template>
246                     <xsl:choose><xsl:when test="position()=last()"><xsl:text>.</xsl:text></xsl:when><xsl:otherwise><xsl:text>; </xsl:text></xsl:otherwise></xsl:choose>
247             </xsl:for-each>
248         </span>
249        </xsl:if>
250
251         <xsl:if test="marc:datafield[@tag=130]|marc:datafield[@tag=240]|marc:datafield[@tag=730][@ind2!=2]">
252         <span class="results_summary"><span class="label">Uniform titles: </span>
253         <xsl:for-each select="marc:datafield[@tag=130]|marc:datafield[@tag=240]|marc:datafield[@tag=730][@ind2!=2]">
254             <xsl:variable name="str">
255                 <xsl:for-each select="marc:subfield">
256                     <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'])))">
257                         <xsl:value-of select="text()"/>
258                         <xsl:text> </xsl:text>
259                      </xsl:if>
260                 </xsl:for-each>
261             </xsl:variable>
262             <xsl:call-template name="chopPunctuation">
263                 <xsl:with-param name="chopString">
264                     <xsl:value-of select="substring($str,1,string-length($str)-1)"/>
265                         
266                 </xsl:with-param>
267             </xsl:call-template>
268             <xsl:choose><xsl:when test="position()=last()"><xsl:text>.</xsl:text></xsl:when><xsl:otherwise><xsl:text>; </xsl:text></xsl:otherwise></xsl:choose>
269         </xsl:for-each>
270         </span>
271         </xsl:if>
272
273         <xsl:if test="marc:datafield[substring(@tag, 1, 1) = '6']">
274             <span class="results_summary"><span class="label">Related Subjects: </span>
275             <xsl:for-each select="marc:datafield[substring(@tag, 1, 1) = '6']">
276             <a>
277             <xsl:choose>
278             <xsl:when test="marc:subfield[@code=9]">
279                 <xsl:attribute name="href">/cgi-bin/koha/opac-search.pl?q=an:<xsl:value-of select="marc:subfield[@code=9]"/></xsl:attribute>
280             </xsl:when>
281             <xsl:otherwise>
282                 <xsl:attribute name="href">/cgi-bin/koha/opac-search.pl?q=su:<xsl:value-of select="marc:subfield[@code='a']"/></xsl:attribute>
283             </xsl:otherwise>
284             </xsl:choose>
285             <xsl:call-template name="chopPunctuation">
286                 <xsl:with-param name="chopString">
287                     <xsl:call-template name="subfieldSelect">
288                         <xsl:with-param name="codes">abcdvxyz</xsl:with-param>
289                         <xsl:with-param name="subdivCodes">vxyz</xsl:with-param>
290                         <xsl:with-param name="subdivDelimiter">-- </xsl:with-param>
291                     </xsl:call-template>
292                 </xsl:with-param>
293             </xsl:call-template>
294             </a>
295             <xsl:choose>
296             <xsl:when test="position()=last()"></xsl:when>
297             <xsl:otherwise> | </xsl:otherwise>
298             </xsl:choose>
299
300             </xsl:for-each>
301             </span>
302         </xsl:if>
303
304         <xsl:if test="marc:datafield[@tag=856]">
305         <span class="results_summary"><span class="label">Online Resources: </span>
306         <xsl:for-each select="marc:datafield[@tag=856]">
307             <a><xsl:attribute name="href"><xsl:value-of select="marc:subfield[@code='u']"/></xsl:attribute>
308         <xsl:choose>
309             <xsl:when test="marc:subfield[@code='y' or @code='3' or @code='z']">
310                     <xsl:call-template name="subfieldSelect">
311                         <xsl:with-param name="codes">y3z</xsl:with-param>
312                     </xsl:call-template>
313             </xsl:when>
314         <xsl:when test="not(marc:subfield[@code='y']) and not(marc:subfield[@code='3']) and not(marc:subfield[@code='z'])">
315         Click here to access online
316         </xsl:when>
317         </xsl:choose>
318         </a>
319             <xsl:choose>
320             <xsl:when test="position()=last()"></xsl:when>
321             <xsl:otherwise> | </xsl:otherwise>
322             </xsl:choose>
323             
324         </xsl:for-each>
325         </span>
326         </xsl:if>
327         <xsl:if test="marc:datafield[@tag=505]">
328         <xsl:for-each select="marc:datafield[@tag=505]">
329         <span class="results_summary"><span class="label">
330         <xsl:choose>
331         <xsl:when test="@ind1=0">
332             Contents:
333         </xsl:when>
334         <xsl:when test="@ind1=1">
335             Incomplete contents:
336         </xsl:when>
337         <xsl:when test="@ind1=1">
338             Partial contents:
339         </xsl:when>
340         </xsl:choose>  
341         </span>
342         <xsl:choose>
343         <xsl:when test="@ind2=0">
344             <xsl:for-each select="marc:subfield[@code='t']">
345                 <xsl:value-of select="marc:subfield[@code=t]"/> <xsl:value-of select="marc:subfield[@code=r]"/>
346             </xsl:for-each> 
347         </xsl:when>
348         <xsl:otherwise>
349             <xsl:call-template name="subfieldSelect">
350                 <xsl:with-param name="codes">au</xsl:with-param>
351             </xsl:call-template>
352         </xsl:otherwise>
353         </xsl:choose>
354         </span>
355         </xsl:for-each>
356         </xsl:if>
357
358         <!-- 780 -->
359         <xsl:if test="marc:datafield[@tag=780]">
360         <xsl:for-each select="marc:datafield[@tag=780]">
361         <span class="results_summary"><span class="label">
362         <xsl:choose>
363         <xsl:when test="@ind2=0">
364             Continues:
365         </xsl:when>
366         <xsl:when test="@ind2=1">
367             Continues in part:
368         </xsl:when>
369         <xsl:when test="@ind2=2">
370             Supersedes:
371         </xsl:when>
372         <xsl:when test="@ind2=3">
373             Supersedes in part:
374         </xsl:when>
375         <xsl:when test="@ind2=4">
376             Formed by the union: ... and: ...
377         </xsl:when>
378         <xsl:when test="@ind2=5">
379             Absorbed:
380         </xsl:when>
381         <xsl:when test="@ind2=6">
382             Absorbed in part:
383         </xsl:when>
384         <xsl:when test="@ind2=7">
385             Separated from:
386         </xsl:when>
387         </xsl:choose>
388         </span>
389                 <xsl:variable name="f780">
390                     <xsl:call-template name="subfieldSelect">
391                         <xsl:with-param name="codes">at</xsl:with-param>
392                     </xsl:call-template>
393                 </xsl:variable>
394              <a><xsl:attribute name="href">/cgi-bin/koha/opac-search.pl?q=<xsl:value-of select="translate($f780, '()', '')"/></xsl:attribute>
395                 <xsl:value-of select="translate($f780, '()', '')"/>
396             </a>
397         </span>
398  
399         <xsl:choose>
400         <xsl:when test="@ind1=0">
401             <span class="results_summary"><xsl:value-of select="marc:subfield[@code='n']"/></span>
402         </xsl:when>
403         </xsl:choose>
404
405         </xsl:for-each>
406         </xsl:if>
407
408         <!-- 785 -->
409         <xsl:if test="marc:datafield[@tag=785]">
410         <xsl:for-each select="marc:datafield[@tag=785]">
411         <span class="results_summary"><span class="label">
412         <xsl:choose>
413         <xsl:when test="@ind2=0">
414             Continued by:
415         </xsl:when>
416         <xsl:when test="@ind2=1">
417             Continued in part by:
418         </xsl:when>
419         <xsl:when test="@ind2=2">
420             Superseded by:
421         </xsl:when>
422         <xsl:when test="@ind2=3">
423             Superseded in part by:
424         </xsl:when>
425         <xsl:when test="@ind2=4">
426             Absorbed by:
427         </xsl:when>
428         <xsl:when test="@ind2=5">
429             Absorbed in part by:
430         </xsl:when>
431         <xsl:when test="@ind2=6">
432             Split into .. and ...:
433         </xsl:when>
434         <xsl:when test="@ind2=7">
435             Merged with ... to form ...
436         </xsl:when>
437         <xsl:when test="@ind2=8">
438             Changed back to:
439         </xsl:when>
440
441         </xsl:choose>
442         </span>
443                    <xsl:variable name="f785">
444                     <xsl:call-template name="subfieldSelect">
445                         <xsl:with-param name="codes">at</xsl:with-param>
446                     </xsl:call-template>
447                 </xsl:variable>
448
449                 <a><xsl:attribute name="href">/cgi-bin/koha/opac-search.pl?q=<xsl:value-of select="translate($f785, '()', '')"/></xsl:attribute>
450                 <xsl:value-of select="translate($f785, '()', '')"/>
451             </a>
452
453         </span>
454         </xsl:for-each>
455         </xsl:if>
456
457     </xsl:template>
458
459     <xsl:template name="nameABCDQ">
460             <xsl:call-template name="chopPunctuation">
461                 <xsl:with-param name="chopString">
462                     <xsl:call-template name="subfieldSelect">
463                         <xsl:with-param name="codes">aq</xsl:with-param>
464                     </xsl:call-template>
465                 </xsl:with-param>
466                 <xsl:with-param name="punctuation">
467                     <xsl:text>:,;/ </xsl:text>
468                 </xsl:with-param>
469             </xsl:call-template>
470         <xsl:call-template name="termsOfAddress"/>
471     </xsl:template>
472
473     <xsl:template name="nameABCDN">
474         <xsl:for-each select="marc:subfield[@code='a']">
475                 <xsl:call-template name="chopPunctuation">
476                     <xsl:with-param name="chopString" select="."/>
477                 </xsl:call-template>
478         </xsl:for-each>
479         <xsl:for-each select="marc:subfield[@code='b']">
480                 <xsl:value-of select="."/>
481         </xsl:for-each>
482         <xsl:if test="marc:subfield[@code='c'] or marc:subfield[@code='d'] or marc:subfield[@code='n']">
483                 <xsl:call-template name="subfieldSelect">
484                     <xsl:with-param name="codes">cdn</xsl:with-param>
485                 </xsl:call-template>
486         </xsl:if>
487     </xsl:template>
488
489     <xsl:template name="nameACDEQ">
490             <xsl:call-template name="subfieldSelect">
491                 <xsl:with-param name="codes">acdeq</xsl:with-param>
492             </xsl:call-template>
493     </xsl:template>
494     <xsl:template name="termsOfAddress">
495         <xsl:if test="marc:subfield[@code='b' or @code='c']">
496             <xsl:call-template name="chopPunctuation">
497                 <xsl:with-param name="chopString">
498                     <xsl:call-template name="subfieldSelect">
499                         <xsl:with-param name="codes">bc</xsl:with-param>
500                     </xsl:call-template>
501                 </xsl:with-param>
502             </xsl:call-template>
503         </xsl:if>
504     </xsl:template>
505
506     <xsl:template name="part">
507         <xsl:variable name="partNumber">
508             <xsl:call-template name="specialSubfieldSelect">
509                 <xsl:with-param name="axis">n</xsl:with-param>
510                 <xsl:with-param name="anyCodes">n</xsl:with-param>
511                 <xsl:with-param name="afterCodes">fghkdlmor</xsl:with-param>
512             </xsl:call-template>
513         </xsl:variable>
514         <xsl:variable name="partName">
515             <xsl:call-template name="specialSubfieldSelect">
516                 <xsl:with-param name="axis">p</xsl:with-param>
517                 <xsl:with-param name="anyCodes">p</xsl:with-param>
518                 <xsl:with-param name="afterCodes">fghkdlmor</xsl:with-param>
519             </xsl:call-template>
520         </xsl:variable>
521         <xsl:if test="string-length(normalize-space($partNumber))">
522                 <xsl:call-template name="chopPunctuation">
523                     <xsl:with-param name="chopString" select="$partNumber"/>
524                 </xsl:call-template>
525         </xsl:if>
526         <xsl:if test="string-length(normalize-space($partName))">
527                 <xsl:call-template name="chopPunctuation">
528                     <xsl:with-param name="chopString" select="$partName"/>
529                 </xsl:call-template>
530         </xsl:if>
531     </xsl:template>
532
533     <xsl:template name="specialSubfieldSelect">
534         <xsl:param name="anyCodes"/>
535         <xsl:param name="axis"/>
536         <xsl:param name="beforeCodes"/>
537         <xsl:param name="afterCodes"/>
538         <xsl:variable name="str">
539             <xsl:for-each select="marc:subfield">
540                 <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])">
541                     <xsl:value-of select="text()"/>
542                     <xsl:text> </xsl:text>
543                 </xsl:if>
544             </xsl:for-each>
545         </xsl:variable>
546         <xsl:value-of select="substring($str,1,string-length($str)-1)"/>
547     </xsl:template>
548 </xsl:stylesheet>