Bug 15505: Mark Hold Items 'On hold' instead of 'Available'
[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   xmlns:str="http://exslt.org/strings"
10   exclude-result-prefixes="marc items str">
11
12 <xsl:import href="UNIMARCslimUtils.xsl"/>
13 <xsl:output method = "html" indent="yes" omit-xml-declaration = "yes" encoding="UTF-8"/>
14 <xsl:template match="/">
15   <xsl:apply-templates/>
16 </xsl:template>
17
18 <xsl:template match="marc:record">
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:datafield[@tag=090]/marc:subfield[@code='a']"/>
23   <xsl:variable name="DisplayOPACiconsXSLT" select="marc:sysprefs/marc:syspref[@name='DisplayOPACiconsXSLT']"/>
24   <xsl:variable name="OPACURLOpenInNewWindow" select="marc:sysprefs/marc:syspref[@name='OPACURLOpenInNewWindow']"/>
25   <xsl:variable name="URLLinkText" select="marc:sysprefs/marc:syspref[@name='URLLinkText']"/>
26
27   <xsl:if test="marc:datafield[@tag=200]">
28     <xsl:for-each select="marc:datafield[@tag=200]">
29       <h1 class="title">
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   <xsl:call-template name="tag_title">
71     <xsl:with-param name="tag">454</xsl:with-param>
72     <xsl:with-param name="label">Translation of</xsl:with-param>
73     <xsl:with-param name="spanclass">original_title</xsl:with-param>
74   </xsl:call-template>
75
76   <xsl:call-template name="tag_title">
77     <xsl:with-param name="tag">461</xsl:with-param>
78     <xsl:with-param name="label">Set Level</xsl:with-param>
79     <xsl:with-param name="spanclass">set_level</xsl:with-param>
80   </xsl:call-template>
81
82   <xsl:call-template name="tag_title">
83     <xsl:with-param name="tag">464</xsl:with-param>
84     <xsl:with-param name="label">Piece-Analytic Level</xsl:with-param>
85     <xsl:with-param name="spanclass">piece_analytic_level</xsl:with-param>
86   </xsl:call-template>
87
88   <xsl:call-template name="tag_7xx">
89     <xsl:with-param name="tag">700</xsl:with-param>
90     <xsl:with-param name="label">Main Author</xsl:with-param>
91     <xsl:with-param name="spanclass">main_author</xsl:with-param>
92   </xsl:call-template>
93
94   <xsl:call-template name="tag_7xx">
95     <xsl:with-param name="tag">710</xsl:with-param>
96     <xsl:with-param name="label">Corporate Author (Main)</xsl:with-param>
97     <xsl:with-param name="spanclass">corporate_main_author</xsl:with-param>
98   </xsl:call-template>
99
100   <xsl:call-template name="tag_7xx">
101     <xsl:with-param name="tag">701</xsl:with-param>
102     <xsl:with-param name="label">Coauthor</xsl:with-param>
103     <xsl:with-param name="spanclass">coauthor</xsl:with-param>
104   </xsl:call-template>
105
106   <xsl:call-template name="tag_7xx">
107     <xsl:with-param name="tag">702</xsl:with-param>
108     <xsl:with-param name="label">Secondary Author</xsl:with-param>
109     <xsl:with-param name="spanclass">secondary_author</xsl:with-param>
110   </xsl:call-template>
111
112   <xsl:call-template name="tag_7xx">
113     <xsl:with-param name="tag">711</xsl:with-param>
114     <xsl:with-param name="label">Corporate Author (Coauthor)</xsl:with-param>
115     <xsl:with-param name="spanclass">corporate_coauthor</xsl:with-param>
116   </xsl:call-template>
117
118   <xsl:call-template name="tag_7xx">
119     <xsl:with-param name="tag">712</xsl:with-param>
120     <xsl:with-param name="label">Corporate Author (Secondary)</xsl:with-param>
121     <xsl:with-param name="spanclass">corporate_secondary_author</xsl:with-param>
122   </xsl:call-template>
123
124   <xsl:call-template name="tag_title">
125     <xsl:with-param name="tag">500</xsl:with-param>
126     <xsl:with-param name="label">Uniform Title</xsl:with-param>
127     <xsl:with-param name="spanclass">uniform_title</xsl:with-param>
128   </xsl:call-template>
129
130   <xsl:call-template name="tag_title">
131     <xsl:with-param name="tag">503</xsl:with-param>
132     <xsl:with-param name="label">Uniform Conventional Heading</xsl:with-param>
133     <xsl:with-param name="spanclass">uniform_conventional_heading</xsl:with-param>
134   </xsl:call-template>
135
136   <xsl:if test="marc:datafield[@tag=101]">
137     <span class="results_summary language">
138       <span class="label">Language: </span>
139       <xsl:for-each select="marc:datafield[@tag=101]">
140         <xsl:for-each select="marc:subfield">
141           <xsl:choose>
142             <xsl:when test="@code='b'">of intermediate text, </xsl:when>
143             <xsl:when test="@code='c'">of original work, </xsl:when>
144             <xsl:when test="@code='d'">of summary, </xsl:when>
145             <xsl:when test="@code='e'">of contents page, </xsl:when>
146             <xsl:when test="@code='f'">of title page, </xsl:when>
147             <xsl:when test="@code='g'">of title proper, </xsl:when>
148             <xsl:when test="@code='h'">of libretto, </xsl:when>
149             <xsl:when test="@code='i'">of accompanying material, </xsl:when>
150             <xsl:when test="@code='j'">of subtitles, </xsl:when>
151           </xsl:choose>
152           <xsl:value-of select="text()"/>
153           <xsl:choose>
154             <xsl:when test="position()=last()">
155               <xsl:text>.</xsl:text>
156             </xsl:when>
157             <xsl:otherwise>
158               <xsl:text> ; </xsl:text>
159             </xsl:otherwise>
160           </xsl:choose>
161         </xsl:for-each>
162       </xsl:for-each>
163     </span>
164   </xsl:if>
165
166   <xsl:if test="marc:datafield[@tag=102]">
167           <span class="results_summary country">
168       <span class="label">Country: </span>
169       <xsl:for-each select="marc:datafield[@tag=102]">
170         <xsl:for-each select="marc:subfield">
171           <xsl:value-of select="text()"/>
172           <xsl:choose>
173             <xsl:when test="position()=last()">
174               <xsl:text>.</xsl:text>
175             </xsl:when>
176               <xsl:otherwise><xsl:text>, </xsl:text>
177             </xsl:otherwise>
178           </xsl:choose>
179         </xsl:for-each>
180       </xsl:for-each>
181     </span>
182   </xsl:if>
183
184   <xsl:call-template name="tag_comma">
185     <xsl:with-param name="tag">205</xsl:with-param>
186     <xsl:with-param name="label">Edition Statement</xsl:with-param>
187     <xsl:with-param name="spanclass">edition</xsl:with-param>
188   </xsl:call-template>
189
190   <xsl:call-template name="tag_210" />
191
192   <xsl:call-template name="tag_215" />
193
194   <!-- Build ISBN -->
195   <xsl:if test="marc:datafield[@tag=010]/marc:subfield[@code='a']">
196     <span class="results_summary isbn"><span class="label">ISBN: </span>
197       <xsl:for-each select="marc:datafield[@tag=010]/marc:subfield[@code='a']">
198         <span property="isbn">
199           <xsl:value-of select="."/>
200           <xsl:choose>
201             <xsl:when test="position()=last()">
202               <xsl:text>.</xsl:text>
203             </xsl:when>
204             <xsl:otherwise>
205               <xsl:text>; </xsl:text>
206             </xsl:otherwise>
207           </xsl:choose>
208         </span>
209       </xsl:for-each>
210     </span>
211   </xsl:if>
212
213   <!-- Build ISSN -->
214   <xsl:if test="marc:datafield[@tag=011]/marc:subfield[@code='a']">
215     <span class="results_summary issn"><span class="label">ISSN: </span>
216       <xsl:for-each select="marc:datafield[@tag=011]/marc:subfield[@code='a']">
217         <span property="issn">
218           <xsl:value-of select="."/>
219           <xsl:choose>
220             <xsl:when test="position()=last()">
221               <xsl:text>.</xsl:text>
222             </xsl:when>
223             <xsl:otherwise>
224               <xsl:text>; </xsl:text>
225             </xsl:otherwise>
226           </xsl:choose>
227         </span>
228       </xsl:for-each>
229     </span>
230   </xsl:if>
231
232   <xsl:call-template name="tag_title">
233     <xsl:with-param name="tag">225</xsl:with-param>
234     <xsl:with-param name="label">Series</xsl:with-param>
235     <xsl:with-param name="spanclass">series</xsl:with-param>
236   </xsl:call-template>
237
238   <xsl:if test="marc:datafield[@tag=676]">
239     <span class="results_summary dewey">
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 classification">
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 contents">
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 abstract">
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 provenance">
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 bibliography">
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 thesis">
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 audience">
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 sudoc_serial_history">
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 online_resources">
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 </xsl:template>
447
448     <xsl:template name="nameABCDQ">
449             <xsl:call-template name="chopPunctuation">
450                 <xsl:with-param name="chopString">
451                     <xsl:call-template name="subfieldSelect">
452                         <xsl:with-param name="codes">aq</xsl:with-param>
453                     </xsl:call-template>
454                 </xsl:with-param>
455                 <xsl:with-param name="punctuation">
456                     <xsl:text>:,;/ </xsl:text>
457                 </xsl:with-param>
458             </xsl:call-template>
459         <xsl:call-template name="termsOfAddress"/>
460     </xsl:template>
461
462     <xsl:template name="nameABCDN">
463         <xsl:for-each select="marc:subfield[@code='a']">
464                 <xsl:call-template name="chopPunctuation">
465                     <xsl:with-param name="chopString" select="."/>
466                 </xsl:call-template>
467         </xsl:for-each>
468         <xsl:for-each select="marc:subfield[@code='b']">
469                 <xsl:value-of select="."/>
470         </xsl:for-each>
471         <xsl:if test="marc:subfield[@code='c'] or marc:subfield[@code='d'] or marc:subfield[@code='n']">
472                 <xsl:call-template name="subfieldSelect">
473                     <xsl:with-param name="codes">cdn</xsl:with-param>
474                 </xsl:call-template>
475         </xsl:if>
476     </xsl:template>
477
478     <xsl:template name="nameACDEQ">
479             <xsl:call-template name="subfieldSelect">
480                 <xsl:with-param name="codes">acdeq</xsl:with-param>
481             </xsl:call-template>
482     </xsl:template>
483     <xsl:template name="termsOfAddress">
484         <xsl:if test="marc:subfield[@code='b' or @code='c']">
485             <xsl:call-template name="chopPunctuation">
486                 <xsl:with-param name="chopString">
487                     <xsl:call-template name="subfieldSelect">
488                         <xsl:with-param name="codes">bc</xsl:with-param>
489                     </xsl:call-template>
490                 </xsl:with-param>
491             </xsl:call-template>
492         </xsl:if>
493     </xsl:template>
494
495     <xsl:template name="part">
496         <xsl:variable name="partNumber">
497             <xsl:call-template name="specialSubfieldSelect">
498                 <xsl:with-param name="axis">n</xsl:with-param>
499                 <xsl:with-param name="anyCodes">n</xsl:with-param>
500                 <xsl:with-param name="afterCodes">fghkdlmor</xsl:with-param>
501             </xsl:call-template>
502         </xsl:variable>
503         <xsl:variable name="partName">
504             <xsl:call-template name="specialSubfieldSelect">
505                 <xsl:with-param name="axis">p</xsl:with-param>
506                 <xsl:with-param name="anyCodes">p</xsl:with-param>
507                 <xsl:with-param name="afterCodes">fghkdlmor</xsl:with-param>
508             </xsl:call-template>
509         </xsl:variable>
510         <xsl:if test="string-length(normalize-space($partNumber))">
511                 <xsl:call-template name="chopPunctuation">
512                     <xsl:with-param name="chopString" select="$partNumber"/>
513                 </xsl:call-template>
514         </xsl:if>
515         <xsl:if test="string-length(normalize-space($partName))">
516                 <xsl:call-template name="chopPunctuation">
517                     <xsl:with-param name="chopString" select="$partName"/>
518                 </xsl:call-template>
519         </xsl:if>
520     </xsl:template>
521
522     <xsl:template name="specialSubfieldSelect">
523         <xsl:param name="anyCodes"/>
524         <xsl:param name="axis"/>
525         <xsl:param name="beforeCodes"/>
526         <xsl:param name="afterCodes"/>
527         <xsl:variable name="str">
528             <xsl:for-each select="marc:subfield">
529                 <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])">
530                     <xsl:value-of select="text()"/>
531                     <xsl:text> </xsl:text>
532                 </xsl:if>
533             </xsl:for-each>
534         </xsl:variable>
535         <xsl:value-of select="substring($str,1,string-length($str)-1)"/>
536     </xsl:template>
537
538 </xsl:stylesheet>