Bug 8476: Little bug in OPAC XSLT on OPACURLOpenInNewWindow
[koha.git] / koha-tmpl / opac-tmpl / prog / en / xslt / UNIMARCslim2OPACDetail.xsl
1 <?xml version="1.0" encoding="UTF-8"?>
2
3 <!DOCTYPE stylesheet [<!ENTITY nbsp "&#160;" >]>
4
5 <xsl:stylesheet version="1.0"
6   xmlns:marc="http://www.loc.gov/MARC21/slim"
7   xmlns:items="http://www.koha-community.org/items"
8   xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
9   exclude-result-prefixes="marc items">
10
11 <xsl:import href="UNIMARCslimUtils.xsl"/>
12 <xsl:output method = "xml" indent="yes" omit-xml-declaration = "yes" />
13 <xsl:template match="/">
14   <xsl:apply-templates/>
15 </xsl:template>
16
17 <xsl:template match="marc:record">
18   <xsl:variable name="leader" select="marc:leader"/>
19   <xsl:variable name="leader6" select="substring($leader,7,1)"/>
20   <xsl:variable name="leader7" select="substring($leader,8,1)"/>
21   <xsl:variable name="biblionumber" select="marc:datafield[@tag=090]/marc:subfield[@code='a']"/>
22   <xsl:variable name="DisplayOPACiconsXSLT" select="marc:sysprefs/marc:syspref[@name='DisplayOPACiconsXSLT']"/>
23   <xsl:variable name="OPACURLOpenInNewWindow" select="marc:sysprefs/marc:syspref[@name='OPACURLOpenInNewWindow']"/>
24   <xsl:variable name="URLLinkText" select="marc:sysprefs/marc:syspref[@name='URLLinkText']"/>
25   <xsl:variable name="ShowISBD" select="marc:sysprefs/marc:syspref[@name='viewISBD']"/>
26
27   <xsl:if test="marc:datafield[@tag=200]">
28     <xsl:for-each select="marc:datafield[@tag=200]">
29       <h1>
30         <xsl:call-template name="addClassRtl" />
31         <xsl:for-each select="marc:subfield">
32           <xsl:choose>
33             <xsl:when test="@code='a'">
34               <xsl:variable name="title" select="."/>
35               <xsl:variable name="ntitle"
36                select="translate($title, '&#x0088;&#x0089;&#x0098;&#x009C;','')"/>
37               <xsl:value-of select="$ntitle" />
38             </xsl:when>
39             <xsl:when test="@code='b'">
40               <xsl:text> [</xsl:text>
41               <xsl:value-of select="."/>
42               <xsl:text>]</xsl:text>
43             </xsl:when>
44             <xsl:when test="@code='d'">
45               <xsl:text> = </xsl:text>
46               <xsl:value-of select="."/>
47             </xsl:when>
48             <xsl:when test="@code='e'">
49               <xsl:text> : </xsl:text>
50               <xsl:value-of select="."/>
51             </xsl:when>
52             <xsl:when test="@code='f'">
53               <xsl:text> / </xsl:text>
54               <xsl:value-of select="."/>
55             </xsl:when>
56             <xsl:when test="@code='g'">
57               <xsl:text> ; </xsl:text>
58               <xsl:value-of select="."/>
59             </xsl:when>
60             <xsl:otherwise>
61               <xsl:text>, </xsl:text>
62               <xsl:value-of select="."/>
63             </xsl:otherwise>
64           </xsl:choose>
65         </xsl:for-each>
66       </h1>
67     </xsl:for-each>
68   </xsl:if>
69
70   <div id="views">
71     <span class="view">
72       <span id="Normalview">Normal View</span>
73     </span>
74     <span class="view">
75       <a id="MARCviewPop" href="/cgi-bin/koha/opac-showmarc.pl?id={marc:datafield[@tag=090]/marc:subfield[@code='a']}" title="MARC" rel="gb_page_center[600,500]">MARC View</a>
76     </span>
77     <span class="view">
78       <a id="MARCview" href="/cgi-bin/koha/opac-MARCdetail.pl?biblionumber={marc:datafield[@tag=090]/marc:subfield[@code='a']}" title="MARC">Expanded MARC View</a>
79     </span>
80     <xsl:if test="$ShowISBD!='0'">
81         <span class="view">
82           <a id="ISBDview" href="/cgi-bin/koha/opac-ISBDdetail.pl?biblionumber={marc:datafield[@tag=090]/marc:subfield[@code='a']}">Card View (ISBD)</a>
83         </span>
84     </xsl:if>
85   </div>
86
87   <xsl:call-template name="tag_title">
88     <xsl:with-param name="tag">454</xsl:with-param>
89     <xsl:with-param name="label">Translation of</xsl:with-param>
90   </xsl:call-template>
91
92   <xsl:call-template name="tag_title">
93     <xsl:with-param name="tag">461</xsl:with-param>
94     <xsl:with-param name="label">Set Level</xsl:with-param>
95   </xsl:call-template>
96
97   <xsl:call-template name="tag_title">
98     <xsl:with-param name="tag">464</xsl:with-param>
99     <xsl:with-param name="label">Piece-Analytic Level</xsl:with-param>
100   </xsl:call-template>
101
102   <xsl:call-template name="tag_7xx">
103     <xsl:with-param name="tag">700</xsl:with-param>
104     <xsl:with-param name="label">Main Author</xsl:with-param>
105   </xsl:call-template>
106
107   <xsl:call-template name="tag_7xx">
108     <xsl:with-param name="tag">710</xsl:with-param>
109     <xsl:with-param name="label">Corporate Author (Main)</xsl:with-param>
110   </xsl:call-template>
111
112   <xsl:call-template name="tag_7xx">
113     <xsl:with-param name="tag">701</xsl:with-param>
114     <xsl:with-param name="label">Coauthor</xsl:with-param>
115   </xsl:call-template>
116
117   <xsl:call-template name="tag_7xx">
118     <xsl:with-param name="tag">702</xsl:with-param>
119     <xsl:with-param name="label">Secondary Author</xsl:with-param>
120   </xsl:call-template>
121
122   <xsl:call-template name="tag_7xx">
123     <xsl:with-param name="tag">711</xsl:with-param>
124     <xsl:with-param name="label">Corporate Author (Coauthor)</xsl:with-param>
125   </xsl:call-template>
126
127   <xsl:call-template name="tag_7xx">
128     <xsl:with-param name="tag">712</xsl:with-param>
129     <xsl:with-param name="label">Corporate Author (Secondary)</xsl:with-param>
130   </xsl:call-template>
131
132   <xsl:call-template name="tag_title">
133     <xsl:with-param name="tag">500</xsl:with-param>
134     <xsl:with-param name="label">Uniform Title</xsl:with-param>
135   </xsl:call-template>
136
137   <xsl:call-template name="tag_title">
138     <xsl:with-param name="tag">503</xsl:with-param>
139     <xsl:with-param name="label">Uniform Conventional Heading</xsl:with-param>
140   </xsl:call-template>
141
142   <xsl:if test="marc:datafield[@tag=101]">
143     <span class="results_summary">
144       <span class="label">Language:</span>
145       <xsl:for-each select="marc:datafield[@tag=101]">
146         <xsl:for-each select="marc:subfield">
147           <xsl:choose>
148             <xsl:when test="@code='b'">of intermediate text, </xsl:when>
149             <xsl:when test="@code='c'">of original work, </xsl:when>
150             <xsl:when test="@code='d'">of summary, </xsl:when>
151             <xsl:when test="@code='e'">of contents page, </xsl:when>
152             <xsl:when test="@code='f'">of title page, </xsl:when>
153             <xsl:when test="@code='g'">of title proper, </xsl:when>
154             <xsl:when test="@code='h'">of libretto, </xsl:when>
155             <xsl:when test="@code='i'">of accompanying material, </xsl:when>
156             <xsl:when test="@code='j'">of subtitles, </xsl:when>
157           </xsl:choose>
158           <xsl:value-of select="text()"/>
159           <xsl:choose>
160             <xsl:when test="position()=last()">
161               <xsl:text>.</xsl:text>
162             </xsl:when>
163             <xsl:otherwise>
164               <xsl:text> ; </xsl:text>
165             </xsl:otherwise>
166           </xsl:choose>
167         </xsl:for-each>
168       </xsl:for-each>
169     </span>
170   </xsl:if>
171
172   <xsl:if test="marc:datafield[@tag=102]">
173           <span class="results_summary">
174       <span class="label">Country: </span>
175       <xsl:for-each select="marc:datafield[@tag=102]">
176         <xsl:for-each select="marc:subfield">
177           <xsl:value-of select="text()"/>
178           <xsl:choose>
179             <xsl:when test="position()=last()">
180               <xsl:text>.</xsl:text>
181             </xsl:when>
182               <xsl:otherwise><xsl:text>, </xsl:text>
183             </xsl:otherwise>
184           </xsl:choose>
185         </xsl:for-each>
186       </xsl:for-each>
187     </span>
188   </xsl:if>
189
190   <xsl:call-template name="tag_comma">
191     <xsl:with-param name="tag">205</xsl:with-param>
192     <xsl:with-param name="label">Edition Statement</xsl:with-param>
193   </xsl:call-template>
194
195   <xsl:call-template name="tag_210" />
196
197   <xsl:call-template name="tag_215" />
198
199   <xsl:if test="marc:datafield[@tag=010]/marc:subfield[@code='a']">
200     <span class="results_summary"><span class="label">ISBN: </span>
201     <xsl:for-each select="marc:datafield[@tag=010]">
202       <xsl:variable name="isbn" select="marc:subfield[@code='a']"/>
203       <xsl:value-of select="marc:subfield[@code='a']"/>
204       <xsl:choose>
205         <xsl:when test="position()=last()">
206           <xsl:text>.</xsl:text>
207         </xsl:when>
208         <xsl:otherwise>
209           <xsl:text> ; </xsl:text>
210         </xsl:otherwise>
211       </xsl:choose>
212     </xsl:for-each>
213     </span>
214   </xsl:if>
215
216   <xsl:if test="marc:datafield[@tag=011]">
217     <span class="results_summary">
218       <span class="label">ISSN: </span>
219       <xsl:for-each select="marc:datafield[@tag=011]">
220         <xsl:value-of select="marc:subfield[@code='a']"/>
221         <xsl:choose>
222           <xsl:when test="position()=last()">
223             <xsl:text>.</xsl:text>
224           </xsl:when>
225           <xsl:otherwise>
226             <xsl:text>; </xsl:text>
227           </xsl:otherwise>
228         </xsl:choose>
229       </xsl:for-each>
230     </span>
231   </xsl:if>
232
233   <xsl:call-template name="tag_title">
234     <xsl:with-param name="tag">225</xsl:with-param>
235     <xsl:with-param name="label">Series</xsl:with-param>
236   </xsl:call-template>
237
238   <xsl:if test="marc:datafield[@tag=676]">
239     <span class="results_summary">
240     <span class="label">Dewey: </span>
241       <xsl:for-each select="marc:datafield[@tag=676]">
242         <xsl:value-of select="marc:subfield[@code='a']"/>
243         <xsl:if test="marc:subfield[@code='v']">
244           <xsl:text>, </xsl:text>
245           <xsl:value-of select="marc:subfield[@code='v']"/>
246         </xsl:if>
247         <xsl:if test="marc:subfield[@code='z']">
248           <xsl:text>, </xsl:text>
249           <xsl:value-of select="marc:subfield[@code='z']"/>
250         </xsl:if>
251         <xsl:if test="not (position()=last())">
252           <xsl:text> ; </xsl:text>
253         </xsl:if>
254       </xsl:for-each>
255     </span>
256   </xsl:if>
257
258   <xsl:if test="marc:datafield[@tag=686]">
259     <span class="results_summary">
260     <span class="label">Classification: </span>
261       <xsl:for-each select="marc:datafield[@tag=686]">
262         <xsl:value-of select="marc:subfield[@code='a']"/>
263         <xsl:if test="marc:subfield[@code='b']">
264           <xsl:text>, </xsl:text>
265           <xsl:value-of select="marc:subfield[@code='b']"/>
266         </xsl:if>
267         <xsl:if test="marc:subfield[@code='c']">
268           <xsl:text>, </xsl:text>
269           <xsl:value-of select="marc:subfield[@code='c']"/>
270         </xsl:if>
271         <xsl:if test="not (position()=last())"><xsl:text> ; </xsl:text></xsl:if>
272       </xsl:for-each>
273     </span>
274   </xsl:if>
275
276   <xsl:if test="marc:datafield[@tag=327]">
277     <span class="results_summary">
278       <span class="label">Contents note: </span>
279       <xsl:for-each select="marc:datafield[@tag=327]">
280         <xsl:call-template name="chopPunctuation">
281           <xsl:with-param name="chopString">
282             <xsl:call-template name="subfieldSelect">
283                 <xsl:with-param name="codes">abcdjpvxyz</xsl:with-param>
284                 <xsl:with-param name="subdivCodes">jpxyz</xsl:with-param>
285                 <xsl:with-param name="subdivDelimiter">-- </xsl:with-param>
286             </xsl:call-template>
287           </xsl:with-param>
288         </xsl:call-template>
289       </xsl:for-each>
290     </span>
291   </xsl:if>
292
293   <xsl:if test="marc:datafield[@tag=330]">
294     <span class="results_summary">
295       <span class="label">Abstract: </span>
296       <xsl:for-each select="marc:datafield[@tag=330]">
297         <xsl:value-of select="marc:subfield[@code='a']"/>
298         <xsl:choose>
299           <xsl:when test="position()=last()">
300             <xsl:text>.</xsl:text>
301           </xsl:when>
302           <xsl:otherwise>
303             <xsl:text>; </xsl:text>
304           </xsl:otherwise>
305         </xsl:choose>
306       </xsl:for-each>
307     </span>
308   </xsl:if>
309
310   <xsl:if test="marc:datafield[@tag=317]">
311     <span class="results_summary">
312       <span class="label">Provenance note: </span>
313       <xsl:for-each select="marc:datafield[@tag=317]">
314           <xsl:value-of select="marc:subfield[@code='a']"/>
315       </xsl:for-each>
316     </span>
317   </xsl:if>
318
319   <xsl:if test="marc:datafield[@tag=320]">
320     <span class="results_summary">
321       <span class="label">Bibliography: </span>
322       <xsl:for-each select="marc:datafield[@tag=320]">
323         <xsl:value-of select="marc:subfield[@code='a']"/>
324         <xsl:choose><xsl:when test="position()=last()"><xsl:text>.</xsl:text></xsl:when><xsl:otherwise><xsl:text>; </xsl:text></xsl:otherwise></xsl:choose>
325       </xsl:for-each>
326     </span>
327   </xsl:if>
328
329   <xsl:if test="marc:datafield[@tag=328]">
330     <span class="results_summary">
331       <span class="label">Thesis: </span>
332       <xsl:for-each select="marc:datafield[@tag=328]">
333         <xsl:value-of select="marc:subfield[@code='a']"/>
334         <xsl:choose><xsl:when test="position()=last()"><xsl:text>.</xsl:text></xsl:when><xsl:otherwise><xsl:text>; </xsl:text></xsl:otherwise></xsl:choose>
335       </xsl:for-each>
336     </span>
337   </xsl:if>
338
339   <xsl:if test="marc:datafield[@tag=333]">
340     <span class="results_summary">
341       <span class="label">Audience: </span>
342       <xsl:for-each select="marc:datafield[@tag=333]">
343         <xsl:value-of select="marc:subfield[@code='a']"/>
344         <xsl:choose><xsl:when test="position()=last()"><xsl:text>.</xsl:text></xsl:when><xsl:otherwise><xsl:text>; </xsl:text></xsl:otherwise></xsl:choose>
345       </xsl:for-each>
346     </span>
347   </xsl:if>
348
349   <xsl:if test="marc:datafield[@tag=955]">
350     <span class="results_summary">
351       <span class="label">SUDOC serial history: </span>
352       <xsl:for-each select="marc:datafield[@tag=955]">
353         <xsl:value-of select="marc:subfield[@code='9']"/>:
354         <xsl:value-of select="marc:subfield[@code='r']"/>
355         <xsl:choose><xsl:when test="position()=last()"><xsl:text>.</xsl:text></xsl:when><xsl:otherwise><xsl:text>; </xsl:text></xsl:otherwise></xsl:choose>
356       </xsl:for-each>
357     </span>
358   </xsl:if>
359
360   <xsl:call-template name="tag_subject">
361     <xsl:with-param name="tag">600</xsl:with-param>
362     <xsl:with-param name="label">Subject - Personal Name</xsl:with-param>
363   </xsl:call-template>
364
365   <xsl:call-template name="tag_subject">
366     <xsl:with-param name="tag">601</xsl:with-param>
367     <xsl:with-param name="label">Subject - Corporate Author</xsl:with-param>
368   </xsl:call-template>
369
370   <xsl:call-template name="tag_subject">
371     <xsl:with-param name="tag">602</xsl:with-param>
372     <xsl:with-param name="label">Subject - Family</xsl:with-param>
373   </xsl:call-template>
374
375   <xsl:call-template name="tag_subject">
376     <xsl:with-param name="tag">604</xsl:with-param>
377     <xsl:with-param name="label">Subject - Author/Title</xsl:with-param>
378   </xsl:call-template>
379
380   <xsl:call-template name="tag_subject">
381     <xsl:with-param name="tag">606</xsl:with-param>
382     <xsl:with-param name="label">Subject - Topical Name</xsl:with-param>
383   </xsl:call-template>
384
385   <xsl:call-template name="tag_subject">
386     <xsl:with-param name="tag">607</xsl:with-param>
387     <xsl:with-param name="label">Subject - Geographical Name</xsl:with-param>
388   </xsl:call-template>
389
390   <xsl:call-template name="tag_subject">
391     <xsl:with-param name="tag">608</xsl:with-param>
392     <xsl:with-param name="label">Subject - Form</xsl:with-param>
393   </xsl:call-template>
394
395   <xsl:call-template name="tag_subject">
396     <xsl:with-param name="tag">610</xsl:with-param>
397     <xsl:with-param name="label">Subject</xsl:with-param>
398   </xsl:call-template>
399
400   <xsl:call-template name="tag_subject">
401     <xsl:with-param name="tag">615</xsl:with-param>
402     <xsl:with-param name="label">Subject Category</xsl:with-param>
403   </xsl:call-template>
404
405   <xsl:call-template name="tag_subject">
406     <xsl:with-param name="tag">616</xsl:with-param>
407     <xsl:with-param name="label">Trademark</xsl:with-param>
408   </xsl:call-template>
409
410   <xsl:if test="marc:datafield[@tag=856]">
411     <span class="results_summary">
412       <span class="label">Online Resources:</span>
413       <xsl:for-each select="marc:datafield[@tag=856]">
414         <a>
415           <xsl:attribute name="href">
416             <xsl:value-of select="marc:subfield[@code='u']"/>
417           </xsl:attribute>
418           <xsl:if test="$OPACURLOpenInNewWindow='1'">
419             <xsl:attribute name="target">_blank</xsl:attribute>
420           </xsl:if>
421           <xsl:choose>
422             <xsl:when test="marc:subfield[@code='y' or @code='3' or @code='z']">
423               <xsl:call-template name="subfieldSelect">
424                 <xsl:with-param name="codes">y3z</xsl:with-param>
425               </xsl:call-template>
426             </xsl:when>
427             <xsl:when test="not(marc:subfield[@code='y']) and not(marc:subfield[@code='3']) and not(marc:subfield[@code='z'])">
428               <xsl:choose>
429                 <xsl:when test="$URLLinkText!=''">
430                   <xsl:value-of select="$URLLinkText"/>
431                 </xsl:when>
432                 <xsl:otherwise>
433                   <xsl:text>Click here to access online</xsl:text>
434                 </xsl:otherwise>
435               </xsl:choose>
436             </xsl:when>
437           </xsl:choose>
438         </a>
439         <xsl:choose>
440           <xsl:when test="position()=last()"></xsl:when>
441           <xsl:otherwise> | </xsl:otherwise>
442         </xsl:choose>
443       </xsl:for-each>
444     </span>
445   </xsl:if>
446
447         <!-- 780 -->
448         <xsl:if test="marc:datafield[@tag=780]">
449         <xsl:for-each select="marc:datafield[@tag=780]">
450         <span class="results_summary">
451         <xsl:choose>
452         <xsl:when test="@ind2=0">
453             <span class="label">Continues:</span>
454         </xsl:when>
455         <xsl:when test="@ind2=1">
456             <span class="label">Continues in part:</span>
457         </xsl:when>
458         <xsl:when test="@ind2=2">
459             <span class="label">Supersedes:</span>
460         </xsl:when>
461         <xsl:when test="@ind2=3">
462             <span class="label">Supersedes in part:</span>
463         </xsl:when>
464         <xsl:when test="@ind2=4">
465             <span class="label">Formed by the union: ... and: ...</span>
466         </xsl:when>
467         <xsl:when test="@ind2=5">
468             <span class="label">Absorbed:</span>
469         </xsl:when>
470         <xsl:when test="@ind2=6">
471             <span class="label">Absorbed in part:</span>
472         </xsl:when>
473         <xsl:when test="@ind2=7">
474             <span class="label">Separated from:</span>
475         </xsl:when>
476         </xsl:choose>
477                 <xsl:variable name="f780">
478                     <xsl:call-template name="subfieldSelect">
479                         <xsl:with-param name="codes">a_t</xsl:with-param>
480                     </xsl:call-template>
481                 </xsl:variable>
482              <a><xsl:attribute name="href">/cgi-bin/koha/opac-search.pl?q=<xsl:value-of select="translate($f780, '()', '')"/></xsl:attribute>
483                 <xsl:value-of select="translate($f780, '()', '')"/>
484             </a>
485         </span>
486
487         <xsl:choose>
488         <xsl:when test="@ind1=0">
489             <span class="results_summary"><xsl:value-of select="marc:subfield[@code='n']"/></span>
490         </xsl:when>
491         </xsl:choose>
492
493         </xsl:for-each>
494         </xsl:if>
495
496         <!-- 785 -->
497         <xsl:if test="marc:datafield[@tag=785]">
498         <xsl:for-each select="marc:datafield[@tag=785]">
499         <span class="results_summary">
500         <xsl:choose>
501         <xsl:when test="@ind2=0">
502             <span class="label">Continued by:</span>
503         </xsl:when>
504         <xsl:when test="@ind2=1">
505             <span class="label">Continued in part by:</span>
506         </xsl:when>
507         <xsl:when test="@ind2=2">
508             <span class="label">Superseded by:</span>
509         </xsl:when>
510         <xsl:when test="@ind2=3">
511             <span class="label">Superseded in part by:</span>
512         </xsl:when>
513         <xsl:when test="@ind2=4">
514             <span class="label">Absorbed by:</span>
515         </xsl:when>
516         <xsl:when test="@ind2=5">
517             <span class="label">Absorbed in part by:</span>
518         </xsl:when>
519         <xsl:when test="@ind2=6">
520             <span class="label">Split into .. and ...:</span>
521         </xsl:when>
522         <xsl:when test="@ind2=7">
523             <span class="label">Merged with ... to form ...</span>
524         </xsl:when>
525         <xsl:when test="@ind2=8">
526             <span class="label">Changed back to:</span>
527         </xsl:when>
528
529         </xsl:choose>
530                    <xsl:variable name="f785">
531                     <xsl:call-template name="subfieldSelect">
532                         <xsl:with-param name="codes">a_t</xsl:with-param>
533                     </xsl:call-template>
534                 </xsl:variable>
535
536                 <a><xsl:attribute name="href">/cgi-bin/koha/opac-search.pl?q=<xsl:value-of select="translate($f785, '()', '')"/></xsl:attribute>
537                 <xsl:value-of select="translate($f785, '()', '')"/>
538             </a>
539
540         </span>
541         </xsl:for-each>
542         </xsl:if>
543
544     </xsl:template>
545
546     <xsl:template name="nameABCDQ">
547             <xsl:call-template name="chopPunctuation">
548                 <xsl:with-param name="chopString">
549                     <xsl:call-template name="subfieldSelect">
550                         <xsl:with-param name="codes">aq</xsl:with-param>
551                     </xsl:call-template>
552                 </xsl:with-param>
553                 <xsl:with-param name="punctuation">
554                     <xsl:text>:,;/ </xsl:text>
555                 </xsl:with-param>
556             </xsl:call-template>
557         <xsl:call-template name="termsOfAddress"/>
558     </xsl:template>
559
560     <xsl:template name="nameABCDN">
561         <xsl:for-each select="marc:subfield[@code='a']">
562                 <xsl:call-template name="chopPunctuation">
563                     <xsl:with-param name="chopString" select="."/>
564                 </xsl:call-template>
565         </xsl:for-each>
566         <xsl:for-each select="marc:subfield[@code='b']">
567                 <xsl:value-of select="."/>
568         </xsl:for-each>
569         <xsl:if test="marc:subfield[@code='c'] or marc:subfield[@code='d'] or marc:subfield[@code='n']">
570                 <xsl:call-template name="subfieldSelect">
571                     <xsl:with-param name="codes">cdn</xsl:with-param>
572                 </xsl:call-template>
573         </xsl:if>
574     </xsl:template>
575
576     <xsl:template name="nameACDEQ">
577             <xsl:call-template name="subfieldSelect">
578                 <xsl:with-param name="codes">acdeq</xsl:with-param>
579             </xsl:call-template>
580     </xsl:template>
581     <xsl:template name="termsOfAddress">
582         <xsl:if test="marc:subfield[@code='b' or @code='c']">
583             <xsl:call-template name="chopPunctuation">
584                 <xsl:with-param name="chopString">
585                     <xsl:call-template name="subfieldSelect">
586                         <xsl:with-param name="codes">bc</xsl:with-param>
587                     </xsl:call-template>
588                 </xsl:with-param>
589             </xsl:call-template>
590         </xsl:if>
591     </xsl:template>
592
593     <xsl:template name="part">
594         <xsl:variable name="partNumber">
595             <xsl:call-template name="specialSubfieldSelect">
596                 <xsl:with-param name="axis">n</xsl:with-param>
597                 <xsl:with-param name="anyCodes">n</xsl:with-param>
598                 <xsl:with-param name="afterCodes">fghkdlmor</xsl:with-param>
599             </xsl:call-template>
600         </xsl:variable>
601         <xsl:variable name="partName">
602             <xsl:call-template name="specialSubfieldSelect">
603                 <xsl:with-param name="axis">p</xsl:with-param>
604                 <xsl:with-param name="anyCodes">p</xsl:with-param>
605                 <xsl:with-param name="afterCodes">fghkdlmor</xsl:with-param>
606             </xsl:call-template>
607         </xsl:variable>
608         <xsl:if test="string-length(normalize-space($partNumber))">
609                 <xsl:call-template name="chopPunctuation">
610                     <xsl:with-param name="chopString" select="$partNumber"/>
611                 </xsl:call-template>
612         </xsl:if>
613         <xsl:if test="string-length(normalize-space($partName))">
614                 <xsl:call-template name="chopPunctuation">
615                     <xsl:with-param name="chopString" select="$partName"/>
616                 </xsl:call-template>
617         </xsl:if>
618     </xsl:template>
619
620     <xsl:template name="specialSubfieldSelect">
621         <xsl:param name="anyCodes"/>
622         <xsl:param name="axis"/>
623         <xsl:param name="beforeCodes"/>
624         <xsl:param name="afterCodes"/>
625         <xsl:variable name="str">
626             <xsl:for-each select="marc:subfield">
627                 <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])">
628                     <xsl:value-of select="text()"/>
629                     <xsl:text> </xsl:text>
630                 </xsl:if>
631             </xsl:for-each>
632         </xsl:variable>
633         <xsl:value-of select="substring($str,1,string-length($str)-1)"/>
634     </xsl:template>
635
636 </xsl:stylesheet>