Bug 16522: (follow-up) MARC display templates and get_marc_host fixes
[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-214" />
142
143   <xsl:call-template name="tag_215" />
144
145   <xsl:if test="marc:controlfield[@tag=009]">
146     <span class="results_summary tag_009">
147       <span class="label">Tag 009: </span>
148       <xsl:value-of select="marc:controlfield[@tag=009]"/>
149     </span>
150   </xsl:if>
151
152   <!-- Build ISBN -->
153   <xsl:if test="marc:datafield[@tag=010]/marc:subfield[@code='a']">
154     <span class="results_summary isbn">
155       <span class="label">ISBN: </span>
156       <xsl:for-each select="marc:datafield[@tag=010]/marc:subfield[@code='a']">
157         <span property="isbn">
158           <xsl:value-of select="."/>
159           <xsl:choose>
160             <xsl:when test="position()=last()">
161               <xsl:text>.</xsl:text>
162             </xsl:when>
163             <xsl:otherwise>
164               <xsl:text>; </xsl:text>
165             </xsl:otherwise>
166           </xsl:choose>
167         </span>
168       </xsl:for-each>
169     </span>
170   </xsl:if>
171
172   <!-- Build ISSN -->
173   <xsl:if test="marc:datafield[@tag=011]/marc:subfield[@code='a']">
174     <span class="results_summary issn">
175       <span class="label">ISSN: </span>
176       <xsl:for-each select="marc:datafield[@tag=011]/marc:subfield[@code='a']">
177         <span property="issn">
178           <xsl:value-of select="."/>
179           <xsl:choose>
180             <xsl:when test="position()=last()">
181               <xsl:text>.</xsl:text>
182             </xsl:when>
183             <xsl:otherwise>
184               <xsl:text>; </xsl:text>
185             </xsl:otherwise>
186           </xsl:choose>
187         </span>
188       </xsl:for-each>
189     </span>
190   </xsl:if>
191
192   <xsl:call-template name="tag_title">
193     <xsl:with-param name="tag">225</xsl:with-param>
194     <xsl:with-param name="label">Series</xsl:with-param>
195     <xsl:with-param name="spanclass">series</xsl:with-param>
196   </xsl:call-template>
197
198   <xsl:if test="marc:datafield[@tag=676]">
199     <span class="results_summary dewey">
200       <span class="label">Dewey: </span>
201       <xsl:for-each select="marc:datafield[@tag=676]">
202         <xsl:value-of select="marc:subfield[@code='a']"/>
203         <xsl:if test="marc:subfield[@code='v']">
204           <xsl:text>, </xsl:text>
205           <xsl:value-of select="marc:subfield[@code='v']"/>
206         </xsl:if>
207         <xsl:if test="marc:subfield[@code='z']">
208           <xsl:text>, </xsl:text>
209           <xsl:value-of select="marc:subfield[@code='z']"/>
210         </xsl:if>
211         <xsl:if test="not (position()=last())">
212           <xsl:text> ; </xsl:text>
213         </xsl:if>
214       </xsl:for-each>
215     </span>
216   </xsl:if>
217
218   <xsl:if test="marc:datafield[@tag=686]">
219     <span class="results_summary classification">
220       <span class="label">Classification: </span>
221       <xsl:for-each select="marc:datafield[@tag=686]">
222         <xsl:value-of select="marc:subfield[@code='a']"/>
223         <xsl:if test="marc:subfield[@code='b']">
224           <xsl:text>, </xsl:text>
225           <xsl:value-of select="marc:subfield[@code='b']"/>
226         </xsl:if>
227         <xsl:if test="marc:subfield[@code='c']">
228           <xsl:text>, </xsl:text>
229           <xsl:value-of select="marc:subfield[@code='c']"/>
230         </xsl:if>
231         <xsl:if test="not (position()=last())"><xsl:text> ; </xsl:text></xsl:if>
232       </xsl:for-each>
233     </span>
234   </xsl:if>
235
236   <xsl:if test="marc:datafield[@tag=327]">
237     <span class="results_summary contents">
238       <span class="label">Contents note: </span>
239       <xsl:for-each select="marc:datafield[@tag=327]">
240         <xsl:call-template name="chopPunctuation">
241           <xsl:with-param name="chopString">
242             <xsl:call-template name="subfieldSelect">
243                 <xsl:with-param name="codes">abcdjpvxyz</xsl:with-param>
244                 <xsl:with-param name="subdivCodes">jpxyz</xsl:with-param>
245                 <xsl:with-param name="subdivDelimiter">-- </xsl:with-param>
246             </xsl:call-template>
247           </xsl:with-param>
248         </xsl:call-template>
249       </xsl:for-each>
250     </span>
251   </xsl:if>
252
253   <xsl:if test="marc:datafield[@tag=330]">
254     <span class="results_summary abstract">
255       <span class="label">Abstract: </span>
256       <xsl:for-each select="marc:datafield[@tag=330]">
257         <xsl:value-of select="marc:subfield[@code='a']"/>
258         <xsl:choose>
259           <xsl:when test="position()=last()">
260             <xsl:text>.</xsl:text>
261           </xsl:when>
262           <xsl:otherwise>
263             <xsl:text>; </xsl:text>
264           </xsl:otherwise>
265         </xsl:choose>
266       </xsl:for-each>
267     </span>
268   </xsl:if>
269
270   <xsl:if test="marc:datafield[@tag=317]">
271     <span class="results_summary provenance">
272       <span class="label">Provenance note: </span>
273       <xsl:for-each select="marc:datafield[@tag=317]">
274           <xsl:value-of select="marc:subfield[@code='a']"/>
275       </xsl:for-each>
276     </span>
277   </xsl:if>
278
279   <xsl:if test="marc:datafield[@tag=320]">
280     <span class="results_summary bibliography">
281       <span class="label">Bibliography: </span>
282       <xsl:for-each select="marc:datafield[@tag=320]">
283         <xsl:value-of select="marc:subfield[@code='a']"/>
284         <xsl:choose><xsl:when test="position()=last()"><xsl:text>.</xsl:text></xsl:when><xsl:otherwise><xsl:text>; </xsl:text></xsl:otherwise></xsl:choose>
285       </xsl:for-each>
286     </span>
287   </xsl:if>
288
289   <xsl:if test="marc:datafield[@tag=328]">
290     <span class="results_summary thesis">
291       <span class="label">Thesis: </span>
292       <xsl:for-each select="marc:datafield[@tag=328]">
293         <xsl:value-of select="marc:subfield[@code='a']"/>
294         <xsl:choose><xsl:when test="position()=last()"><xsl:text>.</xsl:text></xsl:when><xsl:otherwise><xsl:text>; </xsl:text></xsl:otherwise></xsl:choose>
295       </xsl:for-each>
296     </span>
297   </xsl:if>
298
299   <xsl:if test="marc:datafield[@tag=333]">
300     <span class="results_summary audience">
301       <span class="label">Audience: </span>
302       <xsl:for-each select="marc:datafield[@tag=333]">
303         <xsl:value-of select="marc:subfield[@code='a']"/>
304         <xsl:choose><xsl:when test="position()=last()"><xsl:text>.</xsl:text></xsl:when><xsl:otherwise><xsl:text>; </xsl:text></xsl:otherwise></xsl:choose>
305       </xsl:for-each>
306     </span>
307   </xsl:if>
308
309   <xsl:if test="marc:datafield[@tag=955]">
310     <span class="results_summary sudoc_serial_history">
311       <span class="label">SUDOC serial history: </span>
312       <xsl:for-each select="marc:datafield[@tag=955]">
313         <xsl:value-of select="marc:subfield[@code='9']"/>:
314         <xsl:value-of select="marc:subfield[@code='r']"/>
315         <xsl:choose><xsl:when test="position()=last()"><xsl:text>.</xsl:text></xsl:when><xsl:otherwise><xsl:text>; </xsl:text></xsl:otherwise></xsl:choose>
316       </xsl:for-each>
317     </span>
318   </xsl:if>
319
320   <xsl:call-template name="tag_subject">
321     <xsl:with-param name="tag">600</xsl:with-param>
322     <xsl:with-param name="label">Subject - Personal Name</xsl:with-param>
323   </xsl:call-template>
324
325   <xsl:call-template name="tag_subject">
326     <xsl:with-param name="tag">601</xsl:with-param>
327     <xsl:with-param name="label">Subject - Corporate Author</xsl:with-param>
328   </xsl:call-template>
329
330   <xsl:call-template name="tag_subject">
331     <xsl:with-param name="tag">602</xsl:with-param>
332     <xsl:with-param name="label">Subject - Family</xsl:with-param>
333   </xsl:call-template>
334
335   <xsl:call-template name="tag_subject">
336     <xsl:with-param name="tag">604</xsl:with-param>
337     <xsl:with-param name="label">Subject - Author/Title</xsl:with-param>
338   </xsl:call-template>
339
340   <xsl:call-template name="tag_subject">
341     <xsl:with-param name="tag">606</xsl:with-param>
342     <xsl:with-param name="label">Subject - Topical Name</xsl:with-param>
343   </xsl:call-template>
344
345   <xsl:call-template name="tag_subject">
346     <xsl:with-param name="tag">607</xsl:with-param>
347     <xsl:with-param name="label">Subject - Geographical Name</xsl:with-param>
348   </xsl:call-template>
349
350   <xsl:call-template name="tag_subject">
351     <xsl:with-param name="tag">608</xsl:with-param>
352     <xsl:with-param name="label">Subject - Form</xsl:with-param>
353   </xsl:call-template>
354
355   <xsl:call-template name="tag_subject">
356     <xsl:with-param name="tag">610</xsl:with-param>
357     <xsl:with-param name="label">Subject</xsl:with-param>
358   </xsl:call-template>
359
360   <xsl:call-template name="tag_subject">
361     <xsl:with-param name="tag">615</xsl:with-param>
362     <xsl:with-param name="label">Subject Category</xsl:with-param>
363   </xsl:call-template>
364
365   <xsl:call-template name="tag_subject">
366     <xsl:with-param name="tag">616</xsl:with-param>
367     <xsl:with-param name="label">Trademark</xsl:with-param>
368   </xsl:call-template>
369
370   <xsl:if test="marc:datafield[@tag=856]">
371     <span class="results_summary online_resources">
372       <span class="label">Online Resources:</span>
373       <xsl:for-each select="marc:datafield[@tag=856]">
374         <xsl:variable name="SubqText"><xsl:value-of select="marc:subfield[@code='q']"/></xsl:variable>
375         <a>
376           <xsl:attribute name="href">
377             <xsl:value-of select="marc:subfield[@code='u']"/>
378           </xsl:attribute>
379           <xsl:choose>
380             <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')">
381               <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>
382             </xsl:when>
383             <xsl:when test="marc:subfield[@code='y' or @code='3' or @code='z']">
384               <xsl:call-template name="subfieldSelect">
385                 <xsl:with-param name="codes">y3z</xsl:with-param>
386               </xsl:call-template>
387             </xsl:when>
388             <xsl:when test="not(marc:subfield[@code='y']) and not(marc:subfield[@code='3']) and not(marc:subfield[@code='z'])">
389               Click here to access online
390             </xsl:when>
391           </xsl:choose>
392         </a>
393         <xsl:choose>
394           <xsl:when test="position()=last()"></xsl:when>
395           <xsl:otherwise> | </xsl:otherwise>
396         </xsl:choose>
397       </xsl:for-each>
398     </span>
399   </xsl:if>
400 </xsl:template>
401
402     <xsl:template name="nameABCDQ">
403             <xsl:call-template name="chopPunctuation">
404                 <xsl:with-param name="chopString">
405                     <xsl:call-template name="subfieldSelect">
406                         <xsl:with-param name="codes">aq</xsl:with-param>
407                     </xsl:call-template>
408                 </xsl:with-param>
409                 <xsl:with-param name="punctuation">
410                     <xsl:text>:,;/ </xsl:text>
411                 </xsl:with-param>
412             </xsl:call-template>
413         <xsl:call-template name="termsOfAddress"/>
414     </xsl:template>
415
416     <xsl:template name="nameABCDN">
417         <xsl:for-each select="marc:subfield[@code='a']">
418                 <xsl:call-template name="chopPunctuation">
419                     <xsl:with-param name="chopString" select="."/>
420                 </xsl:call-template>
421         </xsl:for-each>
422         <xsl:for-each select="marc:subfield[@code='b']">
423                 <xsl:value-of select="."/>
424         </xsl:for-each>
425         <xsl:if test="marc:subfield[@code='c'] or marc:subfield[@code='d'] or marc:subfield[@code='n']">
426                 <xsl:call-template name="subfieldSelect">
427                     <xsl:with-param name="codes">cdn</xsl:with-param>
428                 </xsl:call-template>
429         </xsl:if>
430     </xsl:template>
431
432     <xsl:template name="nameACDEQ">
433             <xsl:call-template name="subfieldSelect">
434                 <xsl:with-param name="codes">acdeq</xsl:with-param>
435             </xsl:call-template>
436     </xsl:template>
437     <xsl:template name="termsOfAddress">
438         <xsl:if test="marc:subfield[@code='b' or @code='c']">
439             <xsl:call-template name="chopPunctuation">
440                 <xsl:with-param name="chopString">
441                     <xsl:call-template name="subfieldSelect">
442                         <xsl:with-param name="codes">bc</xsl:with-param>
443                     </xsl:call-template>
444                 </xsl:with-param>
445             </xsl:call-template>
446         </xsl:if>
447     </xsl:template>
448
449     <xsl:template name="part">
450         <xsl:variable name="partNumber">
451             <xsl:call-template name="specialSubfieldSelect">
452                 <xsl:with-param name="axis">n</xsl:with-param>
453                 <xsl:with-param name="anyCodes">n</xsl:with-param>
454                 <xsl:with-param name="afterCodes">fghkdlmor</xsl:with-param>
455             </xsl:call-template>
456         </xsl:variable>
457         <xsl:variable name="partName">
458             <xsl:call-template name="specialSubfieldSelect">
459                 <xsl:with-param name="axis">p</xsl:with-param>
460                 <xsl:with-param name="anyCodes">p</xsl:with-param>
461                 <xsl:with-param name="afterCodes">fghkdlmor</xsl:with-param>
462             </xsl:call-template>
463         </xsl:variable>
464         <xsl:if test="string-length(normalize-space($partNumber))">
465                 <xsl:call-template name="chopPunctuation">
466                     <xsl:with-param name="chopString" select="$partNumber"/>
467                 </xsl:call-template>
468         </xsl:if>
469         <xsl:if test="string-length(normalize-space($partName))">
470                 <xsl:call-template name="chopPunctuation">
471                     <xsl:with-param name="chopString" select="$partName"/>
472                 </xsl:call-template>
473         </xsl:if>
474     </xsl:template>
475
476     <xsl:template name="specialSubfieldSelect">
477         <xsl:param name="anyCodes"/>
478         <xsl:param name="axis"/>
479         <xsl:param name="beforeCodes"/>
480         <xsl:param name="afterCodes"/>
481         <xsl:variable name="str">
482             <xsl:for-each select="marc:subfield">
483                 <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])">
484                     <xsl:value-of select="text()"/>
485                     <xsl:text> </xsl:text>
486                 </xsl:if>
487             </xsl:for-each>
488         </xsl:variable>
489         <xsl:value-of select="substring($str,1,string-length($str)-1)"/>
490     </xsl:template>
491
492 </xsl:stylesheet>