Bug 30430: UNIMARC XSLT add field B214 display
[koha.git] / koha-tmpl / intranet-tmpl / prog / en / xslt / UNIMARCslim2intranetDetail.xsl
1 <?xml version="1.0" encoding="UTF-8"?>
2
3 <!DOCTYPE stylesheet>
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="Show856uAsImage" select="marc:sysprefs/marc:syspref[@name='Display856uAsImage']"/>
19   <xsl:variable name="leader" select="marc:leader"/>
20   <xsl:variable name="leader6" select="substring($leader,7,1)"/>
21   <xsl:variable name="leader7" select="substring($leader,8,1)"/>
22   <xsl:variable name="biblionumber" select="marc:controlfield[@tag=001]"/>
23
24
25   <xsl:if test="marc:datafield[@tag=200]">
26     <xsl:for-each select="marc:datafield[@tag=200]">
27       <h1>
28         <xsl:call-template name="addClassRtl" />
29         <xsl:variable name="title" select="marc:subfield[@code='a']"/>
30         <xsl:variable name="ntitle"
31          select="translate($title, '&#x0098;&#x009C;&#xC29C;&#xC29B;&#xC298;&#xC288;&#xC289;','')"/>
32         <xsl:value-of select="$ntitle" />
33         <xsl:if test="marc:subfield[@code='e']">
34           <xsl:text> : </xsl:text>
35           <xsl:for-each select="marc:subfield[@code='e']">
36             <xsl:value-of select="."/>
37           </xsl:for-each>
38         </xsl:if>
39         <xsl:if test="marc:subfield[@code='b']">
40           <xsl:text> [</xsl:text>
41           <xsl:value-of select="marc:subfield[@code='b']"/>
42           <xsl:text>]</xsl:text>
43         </xsl:if>
44         <xsl:if test="marc:subfield[@code='f']">
45           <xsl:text> / </xsl:text>
46           <xsl:value-of select="marc:subfield[@code='f']"/>
47         </xsl:if>
48         <xsl:if test="marc:subfield[@code='g']">
49           <xsl:text> ; </xsl:text>
50           <xsl:value-of select="marc:subfield[@code='g']"/>
51         </xsl:if>
52       </h1>
53     </xsl:for-each>
54   </xsl:if>
55   <xsl:call-template name="tag_4xx" />
56
57   <xsl:call-template name="tag_7xx">
58     <xsl:with-param name="tag">700</xsl:with-param>
59     <xsl:with-param name="label">Main Author</xsl:with-param>
60     <xsl:with-param name="spanclass">main_author</xsl:with-param>
61   </xsl:call-template>
62
63   <xsl:call-template name="tag_7xx">
64     <xsl:with-param name="tag">710</xsl:with-param>
65     <xsl:with-param name="label">Corporate Author (Main)</xsl:with-param>
66     <xsl:with-param name="spanclass">corporate_main_author</xsl:with-param>
67   </xsl:call-template>
68
69   <xsl:call-template name="tag_7xx">
70     <xsl:with-param name="tag">701</xsl:with-param>
71     <xsl:with-param name="label">Coauthor</xsl:with-param>
72     <xsl:with-param name="spanclass">coauthor</xsl:with-param>
73   </xsl:call-template>
74
75   <xsl:call-template name="tag_7xx">
76     <xsl:with-param name="tag">702</xsl:with-param>
77     <xsl:with-param name="label">Secondary Author</xsl:with-param>
78     <xsl:with-param name="spanclass">secondary_author</xsl:with-param>
79   </xsl:call-template>
80
81   <xsl:call-template name="tag_7xx">
82     <xsl:with-param name="tag">711</xsl:with-param>
83     <xsl:with-param name="label">Corporate Author (Coauthor)</xsl:with-param>
84     <xsl:with-param name="spanclass">corporate_coauthor</xsl:with-param>
85   </xsl:call-template>
86
87   <xsl:call-template name="tag_7xx">
88     <xsl:with-param name="tag">712</xsl:with-param>
89     <xsl:with-param name="label">Corporate Author (Secondary)</xsl:with-param>
90     <xsl:with-param name="spanclass">corporate_secondary_author</xsl:with-param>
91   </xsl:call-template>
92
93   <xsl:if test="marc:datafield[@tag=101]">
94     <span class="results_summary language">
95       <span class="label">Language: </span>
96       <xsl:for-each select="marc:datafield[@tag=101]">
97         <xsl:for-each select="marc:subfield">
98           <xsl:choose>
99             <xsl:when test="@code='b'">of intermediate text, </xsl:when>
100             <xsl:when test="@code='c'">of original work, </xsl:when>
101             <xsl:when test="@code='d'">of summary, </xsl:when>
102             <xsl:when test="@code='e'">of contents page, </xsl:when>
103             <xsl:when test="@code='f'">of title page, </xsl:when>
104             <xsl:when test="@code='g'">of title proper, </xsl:when>
105             <xsl:when test="@code='h'">of libretto, </xsl:when>
106             <xsl:when test="@code='i'">of accompanying material, </xsl:when>
107             <xsl:when test="@code='j'">of subtitles, </xsl:when>
108           </xsl:choose>
109           <xsl:value-of select="text()"/>
110           <xsl:choose>
111             <xsl:when test="position()=last()">
112               <xsl:text>.</xsl:text>
113             </xsl:when>
114             <xsl:otherwise>
115               <xsl:text> ; </xsl:text>
116             </xsl:otherwise>
117           </xsl:choose>
118         </xsl:for-each>
119       </xsl:for-each>
120     </span>
121   </xsl:if>
122
123   <xsl:if test="marc:datafield[@tag=102]">
124     <span class="results_summary country">
125       <span class="label">Country: </span>
126       <xsl:for-each select="marc:datafield[@tag=102]">
127         <xsl:for-each select="marc:subfield">
128           <xsl:value-of select="text()"/>
129           <xsl:choose>
130             <xsl:when test="position()=last()">
131               <xsl:text>.</xsl:text>
132             </xsl:when>
133               <xsl:otherwise><xsl:text>, </xsl:text>
134             </xsl:otherwise>
135           </xsl:choose>
136         </xsl:for-each>
137       </xsl:for-each>
138     </span>
139   </xsl:if>
140
141   <xsl:call-template name="tag_210" />
142
143   <xsl:call-template name="tag_214" />
144
145   <xsl:call-template name="tag_215" />
146
147   <xsl:if test="marc:controlfield[@tag=009]">
148     <span class="results_summary tag_009">
149       <span class="label">Tag 009: </span>
150       <xsl:value-of select="marc:controlfield[@tag=009]"/>
151     </span>
152   </xsl:if>
153
154   <!-- Build ISBN -->
155   <xsl:if test="marc:datafield[@tag=010]/marc:subfield[@code='a']">
156     <span class="results_summary isbn">
157       <span class="label">ISBN: </span>
158       <xsl:for-each select="marc:datafield[@tag=010]/marc:subfield[@code='a']">
159         <span property="isbn">
160           <xsl:value-of select="."/>
161           <xsl:choose>
162             <xsl:when test="position()=last()">
163               <xsl:text>.</xsl:text>
164             </xsl:when>
165             <xsl:otherwise>
166               <xsl:text>; </xsl:text>
167             </xsl:otherwise>
168           </xsl:choose>
169         </span>
170       </xsl:for-each>
171     </span>
172   </xsl:if>
173
174   <!-- Build ISSN -->
175   <xsl:if test="marc:datafield[@tag=011]/marc:subfield[@code='a']">
176     <span class="results_summary issn">
177       <span class="label">ISSN: </span>
178       <xsl:for-each select="marc:datafield[@tag=011]/marc:subfield[@code='a']">
179         <span property="issn">
180           <xsl:value-of select="."/>
181           <xsl:choose>
182             <xsl:when test="position()=last()">
183               <xsl:text>.</xsl:text>
184             </xsl:when>
185             <xsl:otherwise>
186               <xsl:text>; </xsl:text>
187             </xsl:otherwise>
188           </xsl:choose>
189         </span>
190       </xsl:for-each>
191     </span>
192   </xsl:if>
193
194   <xsl:call-template name="tag_title">
195     <xsl:with-param name="tag">225</xsl:with-param>
196     <xsl:with-param name="label">Series</xsl:with-param>
197     <xsl:with-param name="spanclass">series</xsl:with-param>
198   </xsl:call-template>
199
200   <xsl:if test="marc:datafield[@tag=676]">
201     <span class="results_summary dewey">
202       <span class="label">Dewey: </span>
203       <xsl:for-each select="marc:datafield[@tag=676]">
204         <xsl:value-of select="marc:subfield[@code='a']"/>
205         <xsl:if test="marc:subfield[@code='v']">
206           <xsl:text>, </xsl:text>
207           <xsl:value-of select="marc:subfield[@code='v']"/>
208         </xsl:if>
209         <xsl:if test="marc:subfield[@code='z']">
210           <xsl:text>, </xsl:text>
211           <xsl:value-of select="marc:subfield[@code='z']"/>
212         </xsl:if>
213         <xsl:if test="not (position()=last())">
214           <xsl:text> ; </xsl:text>
215         </xsl:if>
216       </xsl:for-each>
217     </span>
218   </xsl:if>
219
220   <xsl:if test="marc:datafield[@tag=686]">
221     <span class="results_summary classification">
222       <span class="label">Classification: </span>
223       <xsl:for-each select="marc:datafield[@tag=686]">
224         <xsl:value-of select="marc:subfield[@code='a']"/>
225         <xsl:if test="marc:subfield[@code='b']">
226           <xsl:text>, </xsl:text>
227           <xsl:value-of select="marc:subfield[@code='b']"/>
228         </xsl:if>
229         <xsl:if test="marc:subfield[@code='c']">
230           <xsl:text>, </xsl:text>
231           <xsl:value-of select="marc:subfield[@code='c']"/>
232         </xsl:if>
233         <xsl:if test="not (position()=last())"><xsl:text> ; </xsl:text></xsl:if>
234       </xsl:for-each>
235     </span>
236   </xsl:if>
237
238   <xsl:if test="marc:datafield[@tag=327]">
239     <span class="results_summary contents">
240       <span class="label">Contents note: </span>
241       <xsl:for-each select="marc:datafield[@tag=327]">
242         <xsl:call-template name="chopPunctuation">
243           <xsl:with-param name="chopString">
244             <xsl:call-template name="subfieldSelect">
245                 <xsl:with-param name="codes">abcdjpvxyz</xsl:with-param>
246                 <xsl:with-param name="subdivCodes">jpxyz</xsl:with-param>
247                 <xsl:with-param name="subdivDelimiter">-- </xsl:with-param>
248             </xsl:call-template>
249           </xsl:with-param>
250         </xsl:call-template>
251       </xsl:for-each>
252     </span>
253   </xsl:if>
254
255   <xsl:if test="marc:datafield[@tag=330]">
256     <span class="results_summary abstract">
257       <span class="label">Abstract: </span>
258       <xsl:for-each select="marc:datafield[@tag=330]">
259         <xsl:value-of select="marc:subfield[@code='a']"/>
260         <xsl:choose>
261           <xsl:when test="position()=last()">
262             <xsl:text>.</xsl:text>
263           </xsl:when>
264           <xsl:otherwise>
265             <xsl:text>; </xsl:text>
266           </xsl:otherwise>
267         </xsl:choose>
268       </xsl:for-each>
269     </span>
270   </xsl:if>
271
272   <xsl:if test="marc:datafield[@tag=317]">
273     <span class="results_summary provenance">
274       <span class="label">Provenance note: </span>
275       <xsl:for-each select="marc:datafield[@tag=317]">
276           <xsl:value-of select="marc:subfield[@code='a']"/>
277       </xsl:for-each>
278     </span>
279   </xsl:if>
280
281   <xsl:if test="marc:datafield[@tag=320]">
282     <span class="results_summary bibliography">
283       <span class="label">Bibliography: </span>
284       <xsl:for-each select="marc:datafield[@tag=320]">
285         <xsl:value-of select="marc:subfield[@code='a']"/>
286         <xsl:choose><xsl:when test="position()=last()"><xsl:text>.</xsl:text></xsl:when><xsl:otherwise><xsl:text>; </xsl:text></xsl:otherwise></xsl:choose>
287       </xsl:for-each>
288     </span>
289   </xsl:if>
290
291   <xsl:if test="marc:datafield[@tag=328]">
292     <span class="results_summary thesis">
293       <span class="label">Thesis: </span>
294       <xsl:for-each select="marc:datafield[@tag=328]">
295         <xsl:value-of select="marc:subfield[@code='a']"/>
296         <xsl:choose><xsl:when test="position()=last()"><xsl:text>.</xsl:text></xsl:when><xsl:otherwise><xsl:text>; </xsl:text></xsl:otherwise></xsl:choose>
297       </xsl:for-each>
298     </span>
299   </xsl:if>
300
301   <xsl:if test="marc:datafield[@tag=333]">
302     <span class="results_summary audience">
303       <span class="label">Audience: </span>
304       <xsl:for-each select="marc:datafield[@tag=333]">
305         <xsl:value-of select="marc:subfield[@code='a']"/>
306         <xsl:choose><xsl:when test="position()=last()"><xsl:text>.</xsl:text></xsl:when><xsl:otherwise><xsl:text>; </xsl:text></xsl:otherwise></xsl:choose>
307       </xsl:for-each>
308     </span>
309   </xsl:if>
310
311   <xsl:if test="marc:datafield[@tag=955]">
312     <span class="results_summary sudoc_serial_history">
313       <span class="label">SUDOC serial history: </span>
314       <xsl:for-each select="marc:datafield[@tag=955]">
315         <xsl:value-of select="marc:subfield[@code='9']"/>:
316         <xsl:value-of select="marc:subfield[@code='r']"/>
317         <xsl:choose><xsl:when test="position()=last()"><xsl:text>.</xsl:text></xsl:when><xsl:otherwise><xsl:text>; </xsl:text></xsl:otherwise></xsl:choose>
318       </xsl:for-each>
319     </span>
320   </xsl:if>
321
322   <xsl:call-template name="tag_subject">
323     <xsl:with-param name="tag">600</xsl:with-param>
324     <xsl:with-param name="label">Subject - Personal Name</xsl:with-param>
325   </xsl:call-template>
326
327   <xsl:call-template name="tag_subject">
328     <xsl:with-param name="tag">601</xsl:with-param>
329     <xsl:with-param name="label">Subject - Corporate Author</xsl:with-param>
330   </xsl:call-template>
331
332   <xsl:call-template name="tag_subject">
333     <xsl:with-param name="tag">602</xsl:with-param>
334     <xsl:with-param name="label">Subject - Family</xsl:with-param>
335   </xsl:call-template>
336
337   <xsl:call-template name="tag_subject">
338     <xsl:with-param name="tag">604</xsl:with-param>
339     <xsl:with-param name="label">Subject - Author/Title</xsl:with-param>
340   </xsl:call-template>
341
342   <xsl:call-template name="tag_subject">
343     <xsl:with-param name="tag">606</xsl:with-param>
344     <xsl:with-param name="label">Subject - Topical Name</xsl:with-param>
345   </xsl:call-template>
346
347   <xsl:call-template name="tag_subject">
348     <xsl:with-param name="tag">607</xsl:with-param>
349     <xsl:with-param name="label">Subject - Geographical Name</xsl:with-param>
350   </xsl:call-template>
351
352   <xsl:call-template name="tag_subject">
353     <xsl:with-param name="tag">608</xsl:with-param>
354     <xsl:with-param name="label">Subject - Form</xsl:with-param>
355   </xsl:call-template>
356
357   <xsl:call-template name="tag_subject">
358     <xsl:with-param name="tag">610</xsl:with-param>
359     <xsl:with-param name="label">Subject</xsl:with-param>
360   </xsl:call-template>
361
362   <xsl:call-template name="tag_subject">
363     <xsl:with-param name="tag">615</xsl:with-param>
364     <xsl:with-param name="label">Subject Category</xsl:with-param>
365   </xsl:call-template>
366
367   <xsl:call-template name="tag_subject">
368     <xsl:with-param name="tag">616</xsl:with-param>
369     <xsl:with-param name="label">Trademark</xsl:with-param>
370   </xsl:call-template>
371
372   <xsl:if test="marc:datafield[@tag=856]">
373     <span class="results_summary online_resources">
374       <span class="label">Online Resources:</span>
375       <xsl:for-each select="marc:datafield[@tag=856]">
376         <xsl:variable name="SubqText"><xsl:value-of select="marc:subfield[@code='q']"/></xsl:variable>
377         <a>
378           <xsl:attribute name="href">
379             <xsl:value-of select="marc:subfield[@code='u']"/>
380           </xsl:attribute>
381           <xsl:choose>
382             <xsl:when test="($Show856uAsImage='Details' or $Show856uAsImage='Both') and (substring($SubqText,1,6)='image/' or $SubqText='img' or $SubqText='bmp' or $SubqText='cod' or $SubqText='gif' or $SubqText='ief' or $SubqText='jpe' or $SubqText='jpeg' or $SubqText='jpg' or $SubqText='jfif' or $SubqText='png' or $SubqText='svg' or $SubqText='tif' or $SubqText='tiff' or $SubqText='ras' or $SubqText='cmx' or $SubqText='ico' or $SubqText='pnm' or $SubqText='pbm' or $SubqText='pgm' or $SubqText='ppm' or $SubqText='rgb' or $SubqText='xbm' or $SubqText='xpm' or $SubqText='xwd')">
383               <xsl:element name="img"><xsl:attribute name="src"><xsl:value-of select="marc:subfield[@code='u']"/></xsl:attribute><xsl:attribute name="alt"><xsl:value-of select="marc:subfield[@code='y']"/></xsl:attribute><xsl:attribute name="height">100</xsl:attribute></xsl:element><xsl:text></xsl:text>
384             </xsl:when>
385             <xsl:when test="marc:subfield[@code='y' or @code='3' or @code='z']">
386               <xsl:call-template name="subfieldSelect">
387                 <xsl:with-param name="codes">y3z</xsl:with-param>
388               </xsl:call-template>
389             </xsl:when>
390             <xsl:when test="not(marc:subfield[@code='y']) and not(marc:subfield[@code='3']) and not(marc:subfield[@code='z'])">
391               Click here to access online
392             </xsl:when>
393           </xsl:choose>
394         </a>
395         <xsl:choose>
396           <xsl:when test="position()=last()"></xsl:when>
397           <xsl:otherwise> | </xsl:otherwise>
398         </xsl:choose>
399       </xsl:for-each>
400     </span>
401   </xsl:if>
402 </xsl:template>
403
404     <xsl:template name="nameABCDQ">
405             <xsl:call-template name="chopPunctuation">
406                 <xsl:with-param name="chopString">
407                     <xsl:call-template name="subfieldSelect">
408                         <xsl:with-param name="codes">aq</xsl:with-param>
409                     </xsl:call-template>
410                 </xsl:with-param>
411                 <xsl:with-param name="punctuation">
412                     <xsl:text>:,;/ </xsl:text>
413                 </xsl:with-param>
414             </xsl:call-template>
415         <xsl:call-template name="termsOfAddress"/>
416     </xsl:template>
417
418     <xsl:template name="nameABCDN">
419         <xsl:for-each select="marc:subfield[@code='a']">
420                 <xsl:call-template name="chopPunctuation">
421                     <xsl:with-param name="chopString" select="."/>
422                 </xsl:call-template>
423         </xsl:for-each>
424         <xsl:for-each select="marc:subfield[@code='b']">
425                 <xsl:value-of select="."/>
426         </xsl:for-each>
427         <xsl:if test="marc:subfield[@code='c'] or marc:subfield[@code='d'] or marc:subfield[@code='n']">
428                 <xsl:call-template name="subfieldSelect">
429                     <xsl:with-param name="codes">cdn</xsl:with-param>
430                 </xsl:call-template>
431         </xsl:if>
432     </xsl:template>
433
434     <xsl:template name="nameACDEQ">
435             <xsl:call-template name="subfieldSelect">
436                 <xsl:with-param name="codes">acdeq</xsl:with-param>
437             </xsl:call-template>
438     </xsl:template>
439     <xsl:template name="termsOfAddress">
440         <xsl:if test="marc:subfield[@code='b' or @code='c']">
441             <xsl:call-template name="chopPunctuation">
442                 <xsl:with-param name="chopString">
443                     <xsl:call-template name="subfieldSelect">
444                         <xsl:with-param name="codes">bc</xsl:with-param>
445                     </xsl:call-template>
446                 </xsl:with-param>
447             </xsl:call-template>
448         </xsl:if>
449     </xsl:template>
450
451     <xsl:template name="part">
452         <xsl:variable name="partNumber">
453             <xsl:call-template name="specialSubfieldSelect">
454                 <xsl:with-param name="axis">n</xsl:with-param>
455                 <xsl:with-param name="anyCodes">n</xsl:with-param>
456                 <xsl:with-param name="afterCodes">fghkdlmor</xsl:with-param>
457             </xsl:call-template>
458         </xsl:variable>
459         <xsl:variable name="partName">
460             <xsl:call-template name="specialSubfieldSelect">
461                 <xsl:with-param name="axis">p</xsl:with-param>
462                 <xsl:with-param name="anyCodes">p</xsl:with-param>
463                 <xsl:with-param name="afterCodes">fghkdlmor</xsl:with-param>
464             </xsl:call-template>
465         </xsl:variable>
466         <xsl:if test="string-length(normalize-space($partNumber))">
467                 <xsl:call-template name="chopPunctuation">
468                     <xsl:with-param name="chopString" select="$partNumber"/>
469                 </xsl:call-template>
470         </xsl:if>
471         <xsl:if test="string-length(normalize-space($partName))">
472                 <xsl:call-template name="chopPunctuation">
473                     <xsl:with-param name="chopString" select="$partName"/>
474                 </xsl:call-template>
475         </xsl:if>
476     </xsl:template>
477
478     <xsl:template name="specialSubfieldSelect">
479         <xsl:param name="anyCodes"/>
480         <xsl:param name="axis"/>
481         <xsl:param name="beforeCodes"/>
482         <xsl:param name="afterCodes"/>
483         <xsl:variable name="str">
484             <xsl:for-each select="marc:subfield">
485                 <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])">
486                     <xsl:value-of select="text()"/>
487                     <xsl:text> </xsl:text>
488                 </xsl:if>
489             </xsl:for-each>
490         </xsl:variable>
491         <xsl:value-of select="substring($str,1,string-length($str)-1)"/>
492     </xsl:template>
493
494 </xsl:stylesheet>