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