Bug 22672: Change <i> to <em> and <b> to <strong> in templates, includes, xslt
[koha.git] / koha-tmpl / opac-tmpl / bootstrap / en / xslt / UNIMARCslim2OPACResults.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:key name="item-by-status" match="items:item" use="items:status"/>
15 <xsl:key name="item-by-status-and-branch-home" match="items:item" use="concat(items:status, ' ', items:homebranch)"/>
16 <xsl:key name="item-by-status-and-branch-holding" match="items:item" use="concat(items:status, ' ', items:holdingbranch)"/>
17
18 <xsl:template match="/">
19   <xsl:apply-templates/>
20 </xsl:template>
21
22 <xsl:template match="marc:record">
23   <xsl:variable name="leader" select="marc:leader"/>
24   <xsl:variable name="leader6" select="substring($leader,7,1)"/>
25   <xsl:variable name="leader7" select="substring($leader,8,1)"/>
26   <xsl:variable name="biblionumber" select="marc:controlfield[@tag=001]"/>
27   <xsl:variable name="isbn" select="marc:datafield[@tag=010]/marc:subfield[@code='a']"/>
28   <xsl:variable name="OPACResultsLibrary" select="marc:sysprefs/marc:syspref[@name='OPACResultsLibrary']"/>
29   <xsl:variable name="BiblioDefaultView" select="marc:sysprefs/marc:syspref[@name='BiblioDefaultView']"/>
30   <xsl:variable name="hidelostitems" select="marc:sysprefs/marc:syspref[@name='hidelostitems']"/>
31   <xsl:variable name="singleBranchMode" select="marc:sysprefs/marc:syspref[@name='singleBranchMode']"/>
32   <xsl:variable name="OPACURLOpenInNewWindow" select="marc:sysprefs/marc:syspref[@name='OPACURLOpenInNewWindow']"/>
33
34   <xsl:if test="marc:datafield[@tag=200]">
35     <xsl:for-each select="marc:datafield[@tag=200]">
36         <xsl:call-template name="addClassRtl" />
37         <xsl:for-each select="marc:subfield">
38           <xsl:choose>
39             <xsl:when test="@code='a'">
40               <xsl:variable name="title" select="."/>
41               <xsl:variable name="ntitle"
42                 select="translate($title, '&#x0088;&#x0089;&#x0098;&#x009C;','')"/>
43               <a>
44                 <xsl:attribute name="href">
45                   <xsl:call-template name="buildBiblioDefaultViewURL">
46                       <xsl:with-param name="BiblioDefaultView">
47                           <xsl:value-of select="$BiblioDefaultView"/>
48                       </xsl:with-param>
49                   </xsl:call-template>
50                   <xsl:value-of select="str:encode-uri($biblionumber, true())"/>
51                 </xsl:attribute>
52                 <xsl:attribute name="class">title</xsl:attribute>
53                 <xsl:value-of select="$ntitle" />
54               </a>
55             </xsl:when>
56             <xsl:when test="@code='b'">
57               <xsl:text> [</xsl:text>
58               <xsl:value-of select="."/>
59               <xsl:text>]</xsl:text>
60             </xsl:when>
61             <xsl:when test="@code='d'">
62               <xsl:text> = </xsl:text>
63               <xsl:value-of select="."/>
64             </xsl:when>
65             <xsl:when test="@code='e'">
66               <xsl:text> : </xsl:text>
67               <xsl:value-of select="."/>
68             </xsl:when>
69             <xsl:when test="@code='f'">
70               <xsl:text> / </xsl:text>
71               <xsl:value-of select="."/>
72             </xsl:when>
73             <xsl:when test="@code='g'">
74               <xsl:text> ; </xsl:text>
75               <xsl:value-of select="."/>
76             </xsl:when>
77             <xsl:otherwise>
78               <xsl:text>, </xsl:text>
79               <xsl:value-of select="."/>
80             </xsl:otherwise>
81           </xsl:choose>
82         </xsl:for-each>
83     </xsl:for-each>
84   </xsl:if>
85
86   <!-- OpenURL -->
87   <xsl:variable name="OPACShowOpenURL" select="marc:sysprefs/marc:syspref[@name='OPACShowOpenURL']" />
88   <xsl:variable name="OpenURLImageLocation" select="marc:sysprefs/marc:syspref[@name='OpenURLImageLocation']" />
89   <xsl:variable name="OpenURLText" select="marc:sysprefs/marc:syspref[@name='OpenURLText']" />
90   <xsl:variable name="OpenURLResolverURL" select="marc:variables/marc:variable[@name='OpenURLResolverURL']" />
91
92   <xsl:if test="$OPACShowOpenURL = 1 and $OpenURLResolverURL != ''">
93     <xsl:variable name="openurltext">
94       <xsl:choose>
95         <xsl:when test="$OpenURLText != ''">
96           <xsl:value-of select="$OpenURLText" />
97         </xsl:when>
98         <xsl:otherwise>
99           <xsl:text>OpenURL</xsl:text>
100         </xsl:otherwise>
101       </xsl:choose>
102     </xsl:variable>
103
104     <span class="results_summary"><a>
105       <xsl:attribute name="href">
106         <xsl:value-of select="$OpenURLResolverURL" />
107       </xsl:attribute>
108       <xsl:attribute name="title">
109         <xsl:value-of select="$openurltext" />
110       </xsl:attribute>
111       <xsl:attribute name="class">
112         <xsl:text>OpenURL</xsl:text>
113       </xsl:attribute>
114       <xsl:if test="$OPACURLOpenInNewWindow='1'">
115         <xsl:attribute name="target">
116           <xsl:text>_blank</xsl:text>
117         </xsl:attribute>
118       </xsl:if>
119       <xsl:choose>
120         <xsl:when test="$OpenURLImageLocation != ''">
121           <img>
122             <xsl:attribute name="src">
123               <xsl:value-of select="$OpenURLImageLocation" />
124             </xsl:attribute>
125           </img>
126         </xsl:when>
127         <xsl:otherwise>
128           <xsl:value-of select="$openurltext" />
129         </xsl:otherwise>
130       </xsl:choose>
131     </a></span>
132   </xsl:if>
133   <!-- End of OpenURL -->
134
135   <xsl:call-template name="tag_title">
136     <xsl:with-param name="tag">454</xsl:with-param>
137     <xsl:with-param name="label">Translation of</xsl:with-param>
138     <xsl:with-param name="spanclass">original_title</xsl:with-param>
139   </xsl:call-template>
140
141   <xsl:call-template name="tag_title">
142     <xsl:with-param name="tag">461</xsl:with-param>
143     <xsl:with-param name="label">Set Level</xsl:with-param>
144     <xsl:with-param name="spanclass">set_level</xsl:with-param>
145   </xsl:call-template>
146
147   <xsl:call-template name="tag_title">
148     <xsl:with-param name="tag">464</xsl:with-param>
149     <xsl:with-param name="label">Piece-Analytic Level</xsl:with-param>
150     <xsl:with-param name="spanclass">piece_analytic_level</xsl:with-param>
151   </xsl:call-template>
152
153   <xsl:call-template name="tag_210" />
154
155   <xsl:call-template name="tag_215" />
156
157   <span class="results_summary availability">
158     <span class="label">Availability: </span>
159     <xsl:choose>
160       <xsl:when test="marc:datafield[@tag=856]">
161         <xsl:for-each select="marc:datafield[@tag=856]">
162           <xsl:choose>
163             <xsl:when test="@ind2=0">
164               <a>
165                 <xsl:attribute name="href">
166                   <xsl:value-of select="marc:subfield[@code='u']"/>
167                 </xsl:attribute>
168                 <xsl:if test="$OPACURLOpenInNewWindow='1'">
169                     <xsl:attribute name="target">_blank</xsl:attribute>
170                 </xsl:if>
171                 <xsl:choose>
172                   <xsl:when test="marc:subfield[@code='y' or @code='3' or @code='z']">
173                     <xsl:call-template name="subfieldSelect">
174                       <xsl:with-param name="codes">y3z</xsl:with-param>
175                     </xsl:call-template>
176                   </xsl:when>
177                   <xsl:when test="not(marc:subfield[@code='y']) and not(marc:subfield[@code='3']) and not(marc:subfield[@code='z'])">
178                     Click here to access online
179                   </xsl:when>
180                 </xsl:choose>
181               </a>
182               <xsl:choose>
183                 <xsl:when test="position()=last()"></xsl:when>
184                 <xsl:otherwise> | </xsl:otherwise>
185               </xsl:choose>
186             </xsl:when>
187           </xsl:choose>
188         </xsl:for-each>
189       </xsl:when>
190       <xsl:when test="count(key('item-by-status', 'available'))=0 and count(key('item-by-status', 'reference'))=0">
191         No items available
192       </xsl:when>
193       <xsl:when test="count(key('item-by-status', 'available'))>0">
194         <span class="available">
195           <strong><xsl:text>Items available for loan: </xsl:text></strong>
196           <xsl:variable name="available_items" select="key('item-by-status', 'available')"/>
197       <xsl:choose>
198       <xsl:when test="$singleBranchMode=1">
199       <xsl:for-each select="$available_items[generate-id() = generate-id(key('item-by-status-and-branch-home', concat(items:status, ' ', items:homebranch))[1])]">
200         <xsl:if test="items:itemcallnumber != '' and items:itemcallnumber"> [<xsl:value-of select="items:itemcallnumber"/>]</xsl:if>
201           <xsl:text> (</xsl:text>
202           <xsl:value-of select="count(key('item-by-status-and-branch-home', concat(items:status, ' ', items:homebranch)))"/>
203           <xsl:text>)</xsl:text>
204           <xsl:choose><xsl:when test="position()=last()"><xsl:text>. </xsl:text></xsl:when><xsl:otherwise><xsl:text>, </xsl:text></xsl:otherwise></xsl:choose>
205       </xsl:for-each>
206       </xsl:when>
207       <xsl:otherwise>
208           <xsl:choose>
209               <xsl:when test="$OPACResultsLibrary='homebranch'">
210                   <xsl:for-each select="$available_items[generate-id() = generate-id(key('item-by-status-and-branch-home', concat(items:status, ' ', items:homebranch))[1])]">
211                     <xsl:value-of select="items:homebranch"/>
212                         <xsl:if test="items:itemcallnumber != '' and items:itemcallnumber">[<xsl:value-of select="items:itemcallnumber"/>]
213                         </xsl:if>
214                     <xsl:text> (</xsl:text>
215                     <xsl:value-of select="count(key('item-by-status-and-branch-home', concat(items:status, ' ', items:homebranch)))"/>
216                     <xsl:text>)</xsl:text>
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                   </xsl:for-each>
226               </xsl:when>
227               <xsl:otherwise>
228                   <xsl:for-each select="$available_items[generate-id() = generate-id(key('item-by-status-and-branch-holding', concat(items:status, ' ', items:holdingbranch))[1])]">
229                     <xsl:value-of select="items:holdingbranch"/>
230                         <xsl:if test="items:itemcallnumber != '' and items:itemcallnumber">[<xsl:value-of select="items:itemcallnumber"/>]
231                         </xsl:if>
232                     <xsl:text> (</xsl:text>
233                     <xsl:value-of select="count(key('item-by-status-and-branch-holding', concat(items:status, ' ', items:holdingbranch)))"/>
234                     <xsl:text>)</xsl:text>
235                     <xsl:choose>
236                       <xsl:when test="position()=last()">
237                         <xsl:text>. </xsl:text>
238                       </xsl:when>
239                       <xsl:otherwise>
240                         <xsl:text>, </xsl:text>
241                       </xsl:otherwise>
242                     </xsl:choose>
243                   </xsl:for-each>
244               </xsl:otherwise>
245             </xsl:choose>
246       </xsl:otherwise>
247       </xsl:choose>
248         </span>
249       </xsl:when>
250     </xsl:choose>
251     <xsl:choose>
252       <xsl:when test="count(key('item-by-status', 'reference'))>0">
253         <span class="available">
254           <strong><xsl:text>Items available for reference: </xsl:text></strong>
255           <xsl:variable name="reference_items"
256                         select="key('item-by-status', 'reference')"/>
257           <xsl:for-each select="$reference_items[generate-id() = generate-id(key('item-by-status-and-branch-home', concat(items:status, ' ', items:homebranch))[1])]">
258             <xsl:if test="$singleBranchMode=0">
259                 <xsl:value-of select="items:homebranch"/>
260             </xsl:if>
261             <xsl:if test="items:itemcallnumber != '' and items:itemcallnumber">[<xsl:value-of select="items:itemcallnumber"/>]</xsl:if>
262             <xsl:text> (</xsl:text>
263             <xsl:value-of select="count(key('item-by-status-and-branch-home', concat(items:status, ' ', items:homebranch)))"/>
264             <xsl:text>)</xsl:text>
265             <xsl:choose>
266               <xsl:when test="position()=last()">
267                 <xsl:text>. </xsl:text>
268               </xsl:when>
269               <xsl:otherwise>
270                 <xsl:text>, </xsl:text>
271               </xsl:otherwise>
272             </xsl:choose>
273           </xsl:for-each>
274         </span>
275       </xsl:when>
276     </xsl:choose>
277     <xsl:if test="count(key('item-by-status', 'Checked out'))>0">
278       <span class="unavailable">
279         <xsl:text>Checked out (</xsl:text>
280         <xsl:value-of select="count(key('item-by-status', 'Checked out'))"/>
281         <xsl:text>). </xsl:text>
282       </span>
283     </xsl:if>
284     <xsl:if test="count(key('item-by-status', 'Withdrawn'))>0">
285       <span class="unavailable">
286         <xsl:text>Withdrawn (</xsl:text>
287         <xsl:value-of select="count(key('item-by-status', 'Withdrawn'))"/>
288         <xsl:text>). </xsl:text>
289       </span>
290     </xsl:if>
291     <xsl:if test="$hidelostitems='0' and count(key('item-by-status', 'Lost'))>0">
292       <span class="unavailable">
293         <xsl:text>Lost (</xsl:text>
294         <xsl:value-of select="count(key('item-by-status', 'Lost'))"/>
295         <xsl:text>). </xsl:text>
296       </span>
297     </xsl:if>
298     <xsl:if test="count(key('item-by-status', 'Damaged'))>0">
299       <span class="unavailable">
300         <xsl:text>Damaged (</xsl:text>
301         <xsl:value-of select="count(key('item-by-status', 'Damaged'))"/>
302         <xsl:text>). </xsl:text>
303       </span>
304     </xsl:if>
305     <xsl:if test="count(key('item-by-status', 'On order'))>0">
306       <span class="unavailable">
307         <xsl:text>On order (</xsl:text>
308         <xsl:value-of select="count(key('item-by-status', 'On order'))"/>
309         <xsl:text>). </xsl:text>
310       </span>
311     </xsl:if>
312     <xsl:if test="count(key('item-by-status', 'In transit'))>0">
313       <span class="unavailable">
314         <xsl:text>In transit (</xsl:text>
315         <xsl:value-of select="count(key('item-by-status', 'In transit'))"/>
316         <xsl:text>). </xsl:text>
317       </span>
318     </xsl:if>
319     <xsl:if test="count(key('item-by-status', 'Waiting'))>0">
320       <span class="unavailable">
321         <xsl:text>On hold (</xsl:text>
322         <xsl:value-of select="count(key('item-by-status', 'Waiting'))"/>
323         <xsl:text>). </xsl:text>
324       </span>
325     </xsl:if>
326   </span>
327
328 </xsl:template>
329
330 </xsl:stylesheet>