5b91a5c6119fc3c822bf9682720e4ef499c23304
[koha-equinox.git] / koha-tmpl / opac-tmpl / bootstrap / 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:xsl="http://www.w3.org/1999/XSL/Transform"
8   xmlns:str="http://exslt.org/strings"
9   exclude-result-prefixes="marc str">
10
11 <xsl:import href="UNIMARCslimUtils.xsl"/>
12 <xsl:output method = "html" indent="yes" omit-xml-declaration = "yes" encoding="UTF-8"/>
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:controlfield[@tag=001]"/>
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
25   <xsl:if test="marc:datafield[@tag=200]">
26     <xsl:for-each select="marc:datafield[@tag=200]">
27       <h2 class="title">
28         <xsl:call-template name="addClassRtl" />
29         <xsl:for-each select="marc:subfield">
30           <xsl:choose>
31             <xsl:when test="@code='a'">
32               <xsl:variable name="title" select="."/>
33               <xsl:variable name="ntitle"
34                select="translate($title, '&#x0088;&#x0089;&#x0098;&#x009C;','')"/>
35               <xsl:value-of select="$ntitle" />
36             </xsl:when>
37             <xsl:when test="@code='b'">
38               <xsl:text> [</xsl:text>
39               <xsl:value-of select="."/>
40               <xsl:text>]</xsl:text>
41             </xsl:when>
42             <xsl:when test="@code='d'">
43               <xsl:text> = </xsl:text>
44               <xsl:value-of select="."/>
45             </xsl:when>
46             <xsl:when test="@code='e'">
47               <xsl:text> : </xsl:text>
48               <xsl:value-of select="."/>
49             </xsl:when>
50             <xsl:when test="@code='f'">
51               <xsl:text> / </xsl:text>
52               <xsl:value-of select="."/>
53             </xsl:when>
54             <xsl:when test="@code='g'">
55               <xsl:text> ; </xsl:text>
56               <xsl:value-of select="."/>
57             </xsl:when>
58             <xsl:otherwise>
59               <xsl:text>, </xsl:text>
60               <xsl:value-of select="."/>
61             </xsl:otherwise>
62           </xsl:choose>
63         </xsl:for-each>
64       </h2>
65     </xsl:for-each>
66   </xsl:if>
67
68   <xsl:call-template name="tag_title">
69     <xsl:with-param name="tag">454</xsl:with-param>
70     <xsl:with-param name="label">Translation of</xsl:with-param>
71     <xsl:with-param name="spanclass">original_title</xsl:with-param>
72   </xsl:call-template>
73
74   <xsl:call-template name="tag_title">
75     <xsl:with-param name="tag">461</xsl:with-param>
76     <xsl:with-param name="label">Set Level</xsl:with-param>
77     <xsl:with-param name="spanclass">set_level</xsl:with-param>
78   </xsl:call-template>
79
80   <xsl:call-template name="tag_title">
81     <xsl:with-param name="tag">464</xsl:with-param>
82     <xsl:with-param name="label">Piece-Analytic Level</xsl:with-param>
83     <xsl:with-param name="spanclass">piece_analytic_level</xsl:with-param>
84   </xsl:call-template>
85
86   <xsl:call-template name="tag_7xx">
87     <xsl:with-param name="tag">700</xsl:with-param>
88     <xsl:with-param name="label">Main Author</xsl:with-param>
89     <xsl:with-param name="spanclass">main_author</xsl:with-param>
90   </xsl:call-template>
91
92   <xsl:call-template name="tag_7xx">
93     <xsl:with-param name="tag">710</xsl:with-param>
94     <xsl:with-param name="label">Corporate Author (Main)</xsl:with-param>
95     <xsl:with-param name="spanclass">corporate_main_author</xsl:with-param>
96   </xsl:call-template>
97
98   <xsl:call-template name="tag_7xx">
99     <xsl:with-param name="tag">701</xsl:with-param>
100     <xsl:with-param name="label">Coauthor</xsl:with-param>
101     <xsl:with-param name="spanclass">coauthor</xsl:with-param>
102   </xsl:call-template>
103
104   <xsl:call-template name="tag_7xx">
105     <xsl:with-param name="tag">702</xsl:with-param>
106     <xsl:with-param name="label">Secondary Author</xsl:with-param>
107     <xsl:with-param name="spanclass">secondary_author</xsl:with-param>
108   </xsl:call-template>
109
110   <xsl:call-template name="tag_7xx">
111     <xsl:with-param name="tag">711</xsl:with-param>
112     <xsl:with-param name="label">Corporate Author (Coauthor)</xsl:with-param>
113     <xsl:with-param name="spanclass">corporate_coauthor</xsl:with-param>
114   </xsl:call-template>
115
116   <xsl:call-template name="tag_7xx">
117     <xsl:with-param name="tag">712</xsl:with-param>
118     <xsl:with-param name="label">Corporate Author (Secondary)</xsl:with-param>
119     <xsl:with-param name="spanclass">corporate_secondary_author</xsl:with-param>
120   </xsl:call-template>
121
122   <xsl:call-template name="tag_title">
123     <xsl:with-param name="tag">500</xsl:with-param>
124     <xsl:with-param name="label">Uniform Title</xsl:with-param>
125     <xsl:with-param name="spanclass">uniform_title</xsl:with-param>
126   </xsl:call-template>
127
128   <xsl:call-template name="tag_title">
129     <xsl:with-param name="tag">503</xsl:with-param>
130     <xsl:with-param name="label">Uniform Conventional Heading</xsl:with-param>
131     <xsl:with-param name="spanclass">uniform_conventional_heading</xsl:with-param>
132   </xsl:call-template>
133
134   <xsl:if test="marc:datafield[@tag=101]">
135     <span class="results_summary language">
136       <span class="label">Language: </span>
137       <xsl:for-each select="marc:datafield[@tag=101]">
138         <xsl:for-each select="marc:subfield">
139           <xsl:choose>
140             <xsl:when test="@code='b'">of intermediate text, </xsl:when>
141             <xsl:when test="@code='c'">of original work, </xsl:when>
142             <xsl:when test="@code='d'">of summary, </xsl:when>
143             <xsl:when test="@code='e'">of contents page, </xsl:when>
144             <xsl:when test="@code='f'">of title page, </xsl:when>
145             <xsl:when test="@code='g'">of title proper, </xsl:when>
146             <xsl:when test="@code='h'">of libretto, </xsl:when>
147             <xsl:when test="@code='i'">of accompanying material, </xsl:when>
148             <xsl:when test="@code='j'">of subtitles, </xsl:when>
149           </xsl:choose>
150           <xsl:value-of select="text()"/>
151           <xsl:choose>
152             <xsl:when test="position()=last()">
153               <xsl:text>.</xsl:text>
154             </xsl:when>
155             <xsl:otherwise>
156               <xsl:text> ; </xsl:text>
157             </xsl:otherwise>
158           </xsl:choose>
159         </xsl:for-each>
160       </xsl:for-each>
161     </span>
162   </xsl:if>
163
164   <xsl:if test="marc:datafield[@tag=102]">
165           <span class="results_summary country">
166       <span class="label">Country: </span>
167       <xsl:for-each select="marc:datafield[@tag=102]">
168         <xsl:for-each select="marc:subfield">
169           <xsl:value-of select="text()"/>
170           <xsl:choose>
171             <xsl:when test="position()=last()">
172               <xsl:text>.</xsl:text>
173             </xsl:when>
174               <xsl:otherwise><xsl:text>, </xsl:text>
175             </xsl:otherwise>
176           </xsl:choose>
177         </xsl:for-each>
178       </xsl:for-each>
179     </span>
180   </xsl:if>
181
182   <xsl:call-template name="tag_comma">
183     <xsl:with-param name="tag">205</xsl:with-param>
184     <xsl:with-param name="label">Edition Statement</xsl:with-param>
185     <xsl:with-param name="spanclass">edition</xsl:with-param>
186   </xsl:call-template>
187
188   <xsl:call-template name="tag_210" />
189
190   <xsl:call-template name="tag_215" />
191
192   <!-- Build ISBN -->
193   <xsl:if test="marc:datafield[@tag=010]/marc:subfield[@code='a']">
194     <span class="results_summary isbn"><span class="label">ISBN: </span>
195       <xsl:for-each select="marc:datafield[@tag=010]/marc:subfield[@code='a']">
196         <span property="isbn">
197           <xsl:value-of select="."/>
198           <xsl:choose>
199             <xsl:when test="position()=last()">
200               <xsl:text>.</xsl:text>
201             </xsl:when>
202             <xsl:otherwise>
203               <xsl:text>; </xsl:text>
204             </xsl:otherwise>
205           </xsl:choose>
206         </span>
207       </xsl:for-each>
208     </span>
209   </xsl:if>
210
211   <!-- Build ISSN -->
212   <xsl:if test="marc:datafield[@tag=011]/marc:subfield[@code='a']">
213     <span class="results_summary issn"><span class="label">ISSN: </span>
214       <xsl:for-each select="marc:datafield[@tag=011]/marc:subfield[@code='a']">
215         <span property="issn">
216           <xsl:value-of select="."/>
217           <xsl:choose>
218             <xsl:when test="position()=last()">
219               <xsl:text>.</xsl:text>
220             </xsl:when>
221             <xsl:otherwise>
222               <xsl:text>; </xsl:text>
223             </xsl:otherwise>
224           </xsl:choose>
225         </span>
226       </xsl:for-each>
227     </span>
228   </xsl:if>
229
230   <xsl:call-template name="tag_title">
231     <xsl:with-param name="tag">225</xsl:with-param>
232     <xsl:with-param name="label">Series</xsl:with-param>
233     <xsl:with-param name="spanclass">series</xsl:with-param>
234   </xsl:call-template>
235
236   <xsl:if test="marc:datafield[@tag=676]">
237     <span class="results_summary dewey">
238     <span class="label">Dewey: </span>
239       <xsl:for-each select="marc:datafield[@tag=676]">
240         <xsl:value-of select="marc:subfield[@code='a']"/>
241         <xsl:if test="marc:subfield[@code='v']">
242           <xsl:text>, </xsl:text>
243           <xsl:value-of select="marc:subfield[@code='v']"/>
244         </xsl:if>
245         <xsl:if test="marc:subfield[@code='z']">
246           <xsl:text>, </xsl:text>
247           <xsl:value-of select="marc:subfield[@code='z']"/>
248         </xsl:if>
249         <xsl:if test="not (position()=last())">
250           <xsl:text> ; </xsl:text>
251         </xsl:if>
252       </xsl:for-each>
253     </span>
254   </xsl:if>
255
256   <xsl:if test="marc:datafield[@tag=686]">
257     <span class="results_summary classification">
258     <span class="label">Classification: </span>
259       <xsl:for-each select="marc:datafield[@tag=686]">
260         <xsl:value-of select="marc:subfield[@code='a']"/>
261         <xsl:if test="marc:subfield[@code='b']">
262           <xsl:text>, </xsl:text>
263           <xsl:value-of select="marc:subfield[@code='b']"/>
264         </xsl:if>
265         <xsl:if test="marc:subfield[@code='c']">
266           <xsl:text>, </xsl:text>
267           <xsl:value-of select="marc:subfield[@code='c']"/>
268         </xsl:if>
269         <xsl:if test="not (position()=last())"><xsl:text> ; </xsl:text></xsl:if>
270       </xsl:for-each>
271     </span>
272   </xsl:if>
273
274   <xsl:if test="marc:datafield[@tag=327]">
275     <span class="results_summary contents">
276       <span class="label">Contents note: </span>
277       <xsl:for-each select="marc:datafield[@tag=327]">
278         <xsl:call-template name="chopPunctuation">
279           <xsl:with-param name="chopString">
280             <xsl:call-template name="subfieldSelect">
281                 <xsl:with-param name="codes">abcdjpvxyz</xsl:with-param>
282                 <xsl:with-param name="subdivCodes">jpxyz</xsl:with-param>
283                 <xsl:with-param name="subdivDelimiter">-- </xsl:with-param>
284             </xsl:call-template>
285           </xsl:with-param>
286         </xsl:call-template>
287       </xsl:for-each>
288     </span>
289   </xsl:if>
290
291   <xsl:if test="marc:datafield[@tag=330]">
292     <span class="results_summary abstract">
293       <span class="label">Abstract: </span>
294       <xsl:for-each select="marc:datafield[@tag=330]">
295         <xsl:value-of select="marc:subfield[@code='a']"/>
296         <xsl:choose>
297           <xsl:when test="position()=last()">
298             <xsl:text>.</xsl:text>
299           </xsl:when>
300           <xsl:otherwise>
301             <xsl:text>; </xsl:text>
302           </xsl:otherwise>
303         </xsl:choose>
304       </xsl:for-each>
305     </span>
306   </xsl:if>
307
308   <xsl:if test="marc:datafield[@tag=317]">
309     <span class="results_summary provenance">
310       <span class="label">Provenance note: </span>
311       <xsl:for-each select="marc:datafield[@tag=317]">
312           <xsl:value-of select="marc:subfield[@code='a']"/>
313       </xsl:for-each>
314     </span>
315   </xsl:if>
316
317   <xsl:if test="marc:datafield[@tag=320]">
318     <span class="results_summary bibliography">
319       <span class="label">Bibliography: </span>
320       <xsl:for-each select="marc:datafield[@tag=320]">
321         <xsl:value-of select="marc:subfield[@code='a']"/>
322         <xsl:choose><xsl:when test="position()=last()"><xsl:text>.</xsl:text></xsl:when><xsl:otherwise><xsl:text>; </xsl:text></xsl:otherwise></xsl:choose>
323       </xsl:for-each>
324     </span>
325   </xsl:if>
326
327   <xsl:if test="marc:datafield[@tag=328]">
328     <span class="results_summary thesis">
329       <span class="label">Thesis: </span>
330       <xsl:for-each select="marc:datafield[@tag=328]">
331         <xsl:value-of select="marc:subfield[@code='a']"/>
332         <xsl:choose><xsl:when test="position()=last()"><xsl:text>.</xsl:text></xsl:when><xsl:otherwise><xsl:text>; </xsl:text></xsl:otherwise></xsl:choose>
333       </xsl:for-each>
334     </span>
335   </xsl:if>
336
337   <xsl:if test="marc:datafield[@tag=333]">
338     <span class="results_summary audience">
339       <span class="label">Audience: </span>
340       <xsl:for-each select="marc:datafield[@tag=333]">
341         <xsl:value-of select="marc:subfield[@code='a']"/>
342         <xsl:choose><xsl:when test="position()=last()"><xsl:text>.</xsl:text></xsl:when><xsl:otherwise><xsl:text>; </xsl:text></xsl:otherwise></xsl:choose>
343       </xsl:for-each>
344     </span>
345   </xsl:if>
346
347   <xsl:if test="marc:datafield[@tag=955]">
348     <span class="results_summary sudoc_serial_history">
349       <span class="label">SUDOC serial history: </span>
350       <xsl:for-each select="marc:datafield[@tag=955]">
351         <xsl:value-of select="marc:subfield[@code='9']"/>:
352         <xsl:value-of select="marc:subfield[@code='r']"/>
353         <xsl:choose><xsl:when test="position()=last()"><xsl:text>.</xsl:text></xsl:when><xsl:otherwise><xsl:text>; </xsl:text></xsl:otherwise></xsl:choose>
354       </xsl:for-each>
355     </span>
356   </xsl:if>
357
358   <xsl:call-template name="tag_subject">
359     <xsl:with-param name="tag">600</xsl:with-param>
360     <xsl:with-param name="label">Subject - Personal Name</xsl:with-param>
361   </xsl:call-template>
362
363   <xsl:call-template name="tag_subject">
364     <xsl:with-param name="tag">601</xsl:with-param>
365     <xsl:with-param name="label">Subject - Corporate Author</xsl:with-param>
366   </xsl:call-template>
367
368   <xsl:call-template name="tag_subject">
369     <xsl:with-param name="tag">602</xsl:with-param>
370     <xsl:with-param name="label">Subject - Family</xsl:with-param>
371   </xsl:call-template>
372
373   <xsl:call-template name="tag_subject">
374     <xsl:with-param name="tag">604</xsl:with-param>
375     <xsl:with-param name="label">Subject - Author/Title</xsl:with-param>
376   </xsl:call-template>
377
378   <xsl:call-template name="tag_subject">
379     <xsl:with-param name="tag">606</xsl:with-param>
380     <xsl:with-param name="label">Subject - Topical Name</xsl:with-param>
381   </xsl:call-template>
382
383   <xsl:call-template name="tag_subject">
384     <xsl:with-param name="tag">607</xsl:with-param>
385     <xsl:with-param name="label">Subject - Geographical Name</xsl:with-param>
386   </xsl:call-template>
387
388   <xsl:call-template name="tag_subject">
389     <xsl:with-param name="tag">608</xsl:with-param>
390     <xsl:with-param name="label">Subject - Form</xsl:with-param>
391   </xsl:call-template>
392
393   <xsl:call-template name="tag_subject">
394     <xsl:with-param name="tag">610</xsl:with-param>
395     <xsl:with-param name="label">Subject</xsl:with-param>
396   </xsl:call-template>
397
398   <xsl:call-template name="tag_subject">
399     <xsl:with-param name="tag">615</xsl:with-param>
400     <xsl:with-param name="label">Subject Category</xsl:with-param>
401   </xsl:call-template>
402
403   <xsl:call-template name="tag_subject">
404     <xsl:with-param name="tag">616</xsl:with-param>
405     <xsl:with-param name="label">Trademark</xsl:with-param>
406   </xsl:call-template>
407
408   <xsl:if test="marc:datafield[@tag=856]">
409     <span class="results_summary online_resources">
410       <span class="label">Online Resources:</span>
411       <xsl:for-each select="marc:datafield[@tag=856]">
412         <a>
413           <xsl:attribute name="href">
414             <xsl:value-of select="marc:subfield[@code='u']"/>
415           </xsl:attribute>
416           <xsl:if test="$OPACURLOpenInNewWindow='1'">
417             <xsl:attribute name="target">_blank</xsl:attribute>
418           </xsl:if>
419           <xsl:choose>
420             <xsl:when test="marc:subfield[@code='y' or @code='3' or @code='z']">
421               <xsl:call-template name="subfieldSelect">
422                 <xsl:with-param name="codes">y3z</xsl:with-param>
423               </xsl:call-template>
424             </xsl:when>
425             <xsl:when test="not(marc:subfield[@code='y']) and not(marc:subfield[@code='3']) and not(marc:subfield[@code='z'])">
426               <xsl:choose>
427                 <xsl:when test="$URLLinkText!=''">
428                   <xsl:value-of select="$URLLinkText"/>
429                 </xsl:when>
430                 <xsl:otherwise>
431                   <xsl:text>Click here to access online</xsl:text>
432                 </xsl:otherwise>
433               </xsl:choose>
434             </xsl:when>
435           </xsl:choose>
436         </a>
437         <xsl:choose>
438           <xsl:when test="position()=last()"></xsl:when>
439           <xsl:otherwise> | </xsl:otherwise>
440         </xsl:choose>
441       </xsl:for-each>
442     </span>
443   </xsl:if>
444
445   <!-- OpenURL -->
446   <xsl:variable name="OPACShowOpenURL" select="marc:sysprefs/marc:syspref[@name='OPACShowOpenURL']" />
447   <xsl:variable name="OpenURLImageLocation" select="marc:sysprefs/marc:syspref[@name='OpenURLImageLocation']" />
448   <xsl:variable name="OpenURLText" select="marc:sysprefs/marc:syspref[@name='OpenURLText']" />
449   <xsl:variable name="OpenURLResolverURL" select="marc:variables/marc:variable[@name='OpenURLResolverURL']" />
450
451   <xsl:if test="$OPACShowOpenURL = 1 and $OpenURLResolverURL != ''">
452     <xsl:variable name="openurltext">
453       <xsl:choose>
454         <xsl:when test="$OpenURLText != ''">
455           <xsl:value-of select="$OpenURLText" />
456         </xsl:when>
457         <xsl:otherwise>
458           <xsl:text>OpenURL</xsl:text>
459         </xsl:otherwise>
460       </xsl:choose>
461     </xsl:variable>
462
463     <span class="results_summary"><a>
464       <xsl:attribute name="href">
465         <xsl:value-of select="$OpenURLResolverURL" />
466       </xsl:attribute>
467       <xsl:attribute name="title">
468         <xsl:value-of select="$openurltext" />
469       </xsl:attribute>
470       <xsl:attribute name="class">
471         <xsl:text>OpenURL</xsl:text>
472       </xsl:attribute>
473       <xsl:if test="$OPACURLOpenInNewWindow='1'">
474         <xsl:attribute name="target">
475           <xsl:text>_blank</xsl:text>
476         </xsl:attribute>
477       </xsl:if>
478       <xsl:choose>
479         <xsl:when test="$OpenURLImageLocation != ''">
480           <img>
481             <xsl:attribute name="src">
482               <xsl:value-of select="$OpenURLImageLocation" />
483             </xsl:attribute>
484           </img>
485         </xsl:when>
486         <xsl:otherwise>
487           <xsl:value-of select="$openurltext" />
488         </xsl:otherwise>
489       </xsl:choose>
490     </a></span>
491   </xsl:if>
492   <!-- End of OpenURL -->
493
494   <xsl:variable name="OPACShowMusicalInscripts" select="marc:sysprefs/marc:syspref[@name='OPACShowMusicalInscripts']" />
495   <xsl:variable name="OPACPlayMusicalInscripts" select="marc:sysprefs/marc:syspref[@name='OPACPlayMusicalInscripts']" />
496
497   <xsl:if test="$OPACShowMusicalInscripts and marc:datafield[@tag=036]">
498       <xsl:for-each select="marc:datafield[@tag=031]">
499
500         <span class="results_summary musical_inscripts">
501             <xsl:if test="marc:subfield[@code='u']">
502                 <span class="uri">
503                     <a>
504                         <xsl:attribute name="href">
505                             <xsl:value-of select="marc:subfield[@code='u']"/>
506                         </xsl:attribute>
507                         <xsl:text>Audio file</xsl:text>
508                     </a>
509                 </span>
510             </xsl:if>
511             <xsl:if test="marc:subfield[@code='2'] and marc:subfield[@code='2']/text() = 'pe' and marc:subfield[@code='g'] and marc:subfield[@code='n'] and marc:subfield[@code='o'] and marc:subfield[@code='p']">
512                 <div class="inscript" data-system="pae">
513                     <xsl:attribute name="data-clef">
514                         <xsl:value-of select="marc:subfield[@code='g']"/>
515                     </xsl:attribute>
516                     <xsl:attribute name="data-keysig">
517                         <xsl:value-of select="marc:subfield[@code='n']"/>
518                     </xsl:attribute>
519                     <xsl:attribute name="data-timesig">
520                         <xsl:value-of select="marc:subfield[@code='o']"/>
521                     </xsl:attribute>
522                     <xsl:attribute name="data-notation">
523                         <xsl:value-of select="marc:subfield[@code='p']"/>
524                     </xsl:attribute>
525                 </div>
526                 <xsl:if test="$OPACPlayMusicalInscripts = 1">
527                     <div class="audio_controls">
528                         <button class="btn play_btn">
529                             <i id="carticon" class="fa fa-play"></i>
530                             <xsl:text> Play this sample</xsl:text>
531                         </button>
532                     </div>
533                 </xsl:if>
534             </xsl:if>
535         </span>
536     </xsl:for-each>
537     <xsl:if test="$OPACPlayMusicalInscripts = 1">
538         <div class="results_summary">
539             <span class="inscript_audio hide"></span>
540         </div>
541     </xsl:if>
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>