Bug 4371: Display MARC21 field 773 w/XSLT
[koha.git] / koha-tmpl / opac-tmpl / prog / en / xslt / MARC21slim2OPACDetail.xsl
1 <?xml version="1.0" encoding="UTF-8"?>
2 <!-- $Id: MARC21slim2DC.xsl,v 1.1 2003/01/06 08:20:27 adam Exp $ -->
3 <xsl:stylesheet version="1.0"
4   xmlns:marc="http://www.loc.gov/MARC21/slim"
5   xmlns:items="http://www.koha.org/items"
6   xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
7   exclude-result-prefixes="marc items">
8     <xsl:import href="MARC21slimUtils.xsl"/>
9     <xsl:output method = "xml" indent="yes" omit-xml-declaration = "yes" />
10     <xsl:template match="/">
11             <xsl:apply-templates/>
12     </xsl:template>
13
14     <xsl:template match="marc:record">
15
16         <!-- Option: Display Alternate Graphic Representation (MARC 880)  -->
17         <xsl:variable name="display880" select="boolean(marc:datafield[@tag=880])"/>
18
19     <xsl:variable name="DisplayOPACiconsXSLT" select="marc:sysprefs/marc:syspref[@name='DisplayOPACiconsXSLT']"/>
20     <xsl:variable name="OPACURLOpenInNewWindow" select="marc:sysprefs/marc:syspref[@name='OPACURLOpenInNewWindow']"/>
21     <xsl:variable name="URLLinkText" select="marc:sysprefs/marc:syspref[@name='URLLinkText']"/>
22     <xsl:variable name="ShowISBD" select="marc:sysprefs/marc:syspref[@name='viewISBD']"/>
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="controlField008" select="marc:controlfield[@tag=008]"/>
27         <xsl:variable name="materialTypeCode">
28             <xsl:choose>
29                 <xsl:when test="$leader6='a'">
30                     <xsl:choose>
31                         <xsl:when test="$leader7='a' or $leader7='c' or $leader7='d' or $leader7='m'">BK</xsl:when>
32                         <xsl:when test="$leader7='b' or $leader7='i' or $leader7='s'">SE</xsl:when>
33                     </xsl:choose>
34                 </xsl:when>
35                 <xsl:when test="$leader6='t'">BK</xsl:when>
36                 <xsl:when test="$leader6='p'">MX</xsl:when>
37                 <xsl:when test="$leader6='m'">CF</xsl:when>
38                 <xsl:when test="$leader6='e' or $leader6='f'">MP</xsl:when>
39                 <xsl:when test="$leader6='g' or $leader6='k' or $leader6='o' or $leader6='r'">VM</xsl:when>
40                 <xsl:when test="$leader6='i' or $leader6='j'">MU</xsl:when>
41                 <xsl:when test="$leader6='c' or $leader6='d'">PR</xsl:when>
42             </xsl:choose>
43         </xsl:variable>
44         <xsl:variable name="materialTypeLabel">
45             <xsl:choose>
46                 <xsl:when test="$leader6='a'">
47                     <xsl:choose>
48                         <xsl:when test="$leader7='a' or $leader7='c' or $leader7='d' or $leader7='m'">Book</xsl:when>
49                         <xsl:when test="$leader7='b' or $leader7='i' or $leader7='s'">Continuing Resource</xsl:when>
50                     </xsl:choose>
51                 </xsl:when>
52                 <xsl:when test="$leader6='t'">Book</xsl:when>
53                 <xsl:when test="$leader6='p'">Mixed Materials</xsl:when>
54                 <xsl:when test="$leader6='m'">Computer File</xsl:when>
55                 <xsl:when test="$leader6='e' or $leader6='f'">Map</xsl:when>
56                 <xsl:when test="$leader6='g' or $leader6='k' or $leader6='o' or $leader6='r'">Visual Material</xsl:when>
57                 <xsl:when test="$leader6='j'">Music</xsl:when>
58                 <xsl:when test="$leader6='i'">Sound</xsl:when>
59                 <xsl:when test="$leader6='c' or $leader6='d'">Score</xsl:when>
60             </xsl:choose>
61         </xsl:variable>
62
63         <!-- Title Statement -->
64         <!-- Alternate Graphic Representation (MARC 880) -->
65         <xsl:if test="$display880">
66             <h1 class="title">
67                 <xsl:call-template name="m880Select">
68                     <xsl:with-param name="basetags">245</xsl:with-param>
69                     <xsl:with-param name="codes">abhfgknps</xsl:with-param>
70                 </xsl:call-template>
71             </h1>
72         </xsl:if>
73
74         <xsl:if test="marc:datafield[@tag=245]">
75         <h1>
76             <xsl:for-each select="marc:datafield[@tag=245]">
77                     <xsl:call-template name="subfieldSelect">
78                         <xsl:with-param name="codes">a</xsl:with-param>
79                     </xsl:call-template>
80                     <xsl:if test="marc:subfield[@code='b']">
81                         <xsl:text> </xsl:text>
82                         <xsl:call-template name="subfieldSelect">
83                             <xsl:with-param name="codes">b</xsl:with-param>
84                         </xsl:call-template>
85                     </xsl:if>
86                     <xsl:if test="marc:subfield[@code='h']">
87                         <xsl:text> </xsl:text>
88                         <xsl:call-template name="subfieldSelect">
89                             <xsl:with-param name="codes">h</xsl:with-param>
90                         </xsl:call-template>
91                     </xsl:if>
92                 <xsl:text> </xsl:text>
93                     <xsl:call-template name="subfieldSelect">
94                         <xsl:with-param name="codes">fgknps</xsl:with-param>
95                     </xsl:call-template>
96             </xsl:for-each>
97         </h1>
98         </xsl:if>
99
100         <!-- Author Statement: Alternate Graphic Representation (MARC 880) -->
101         <xsl:if test="$display880">
102             <h5 class="author">
103                 <xsl:call-template name="m880Select">
104                     <xsl:with-param name="basetags">100,110,111,700,710,711</xsl:with-param>
105                     <xsl:with-param name="codes">abc</xsl:with-param>
106                     <xsl:with-param name="index">au</xsl:with-param>
107                     <!-- do not use label 'by ' here, it would be repeated for every occurence of 100,110,111,700,710,711 -->
108                 </xsl:call-template>
109             </h5>
110         </xsl:if>
111
112         <xsl:choose>
113         <xsl:when test="marc:datafield[@tag=100] or marc:datafield[@tag=110] or marc:datafield[@tag=111] or marc:datafield[@tag=700] or marc:datafield[@tag=710] or marc:datafield[@tag=711]">
114         <h5 class="author">by
115         <xsl:for-each select="marc:datafield[@tag=100 or @tag=700]">
116         <a>
117         <xsl:choose>
118             <xsl:when test="marc:subfield[@code=9]">
119                 <xsl:attribute name="href">/cgi-bin/koha/opac-search.pl?q=an:<xsl:value-of select="marc:subfield[@code=9]"/></xsl:attribute>
120             </xsl:when>
121             <xsl:otherwise>
122             <xsl:attribute name="href">/cgi-bin/koha/opac-search.pl?q=au:<xsl:value-of select="marc:subfield[@code='a']"/></xsl:attribute>
123             </xsl:otherwise>
124         </xsl:choose>
125         <xsl:call-template name="nameABCDQ"/></a>
126         <xsl:choose>
127         <xsl:when test="position()=last()"><xsl:text>.</xsl:text></xsl:when><xsl:otherwise><xsl:text>; </xsl:text></xsl:otherwise></xsl:choose>
128         </xsl:for-each>
129
130         <xsl:for-each select="marc:datafield[@tag=110 or @tag=710]">
131         <a>
132         <xsl:choose>
133             <xsl:when test="marc:subfield[@code=9]">
134                 <xsl:attribute name="href">/cgi-bin/koha/opac-search.pl?q=an:<xsl:value-of select="marc:subfield[@code=9]"/></xsl:attribute>
135             </xsl:when>
136             <xsl:otherwise>
137             <xsl:attribute name="href">/cgi-bin/koha/opac-search.pl?q=au:<xsl:value-of select="marc:subfield[@code='a']"/></xsl:attribute>      
138             </xsl:otherwise>
139         </xsl:choose>
140         <xsl:call-template name="nameABCDN"/></a>
141         <xsl:choose><xsl:when test="position()=last()"><xsl:text> </xsl:text></xsl:when><xsl:otherwise><xsl:text>; </xsl:text></xsl:otherwise></xsl:choose>
142         </xsl:for-each>
143
144         <xsl:for-each select="marc:datafield[@tag=111 or @tag=711]">
145             <xsl:choose>
146             <xsl:when test="marc:subfield[@code='n']">
147                <xsl:text> </xsl:text>
148                <xsl:call-template name="subfieldSelect">
149                   <xsl:with-param name="codes">n</xsl:with-param>                              </xsl:call-template>
150                <xsl:text> </xsl:text>
151             </xsl:when>
152             </xsl:choose>
153         <a>
154         <xsl:choose>
155             <xsl:when test="marc:subfield[@code=9]">
156                 <xsl:attribute name="href">/cgi-bin/koha/opac-search.pl?q=an:<xsl:value-of select="marc:subfield[@code=9]"/></xsl:attribute>
157             </xsl:when>
158             <xsl:otherwise>
159             <xsl:attribute name="href">/cgi-bin/koha/opac-search.pl?q=au:<xsl:value-of select="marc:subfield[@code='a']"/></xsl:attribute>
160             </xsl:otherwise>
161         </xsl:choose>
162         <xsl:call-template name="nameACDEQ"/></a>
163         <xsl:choose><xsl:when test="position()=last()"><xsl:text>.</xsl:text></xsl:when><xsl:otherwise><xsl:text>; </xsl:text></xsl:otherwise></xsl:choose>
164
165         </xsl:for-each>
166         </h5>
167         </xsl:when>
168         </xsl:choose>
169         <div id="views">
170         <span class="view"><span id="Normalview">Normal View</span> </span>
171         <span class="view"><a id="MARCviewPop" href="/cgi-bin/koha/opac-showmarc.pl?id={marc:datafield[@tag=999]/marc:subfield[@code='c']}" title="MARC" rel="gb_page_center[600,500]">MARC View</a></span>
172         <span class="view"><a id="MARCview" href="/cgi-bin/koha/opac-MARCdetail.pl?biblionumber={marc:datafield[@tag=999]/marc:subfield[@code='c']}" title="MARC">Expanded MARC View</a></span>
173 <xsl:if test="$ShowISBD!='0'">
174         <span class="view"><a id="ISBDview" href="/cgi-bin/koha/opac-ISBDdetail.pl?biblionumber={marc:datafield[@tag=999]/marc:subfield[@code='c']}">Card View (ISBD)</a></span>
175 </xsl:if>
176         </div> 
177
178    <xsl:if test="$DisplayOPACiconsXSLT!='0'">
179         <xsl:if test="$materialTypeCode!=''">
180         <span class="results_summary"><span class="label">Type: </span>
181         <xsl:element name="img"><xsl:attribute name="src">/opac-tmpl/prog/famfamfam/<xsl:value-of select="$materialTypeCode"/>.png</xsl:attribute><xsl:attribute name="alt"></xsl:attribute></xsl:element>
182         <xsl:value-of select="$materialTypeLabel"/>
183         </span>
184         </xsl:if>
185    </xsl:if>
186
187         <!--Series: Alternate Graphic Representation (MARC 880) -->
188         <xsl:if test="$display880">
189             <xsl:call-template name="m880Select">
190                 <xsl:with-param name="basetags">440,490</xsl:with-param>
191                 <xsl:with-param name="codes">av</xsl:with-param>
192                 <xsl:with-param name="class">results_summary</xsl:with-param>
193                 <xsl:with-param name="label">Series: </xsl:with-param>
194                 <xsl:with-param name="index">se</xsl:with-param>
195             </xsl:call-template>
196         </xsl:if>
197         
198         <xsl:if test="marc:datafield[@tag=440 or @tag=490]">
199         <span class="results_summary"><span class="label">Series: </span>
200         <xsl:for-each select="marc:datafield[@tag=440]">
201              <a href="/cgi-bin/koha/opac-search.pl?q=se:{marc:subfield[@code='a']}">
202             <xsl:call-template name="chopPunctuation">
203                             <xsl:with-param name="chopString">
204                                 <xsl:call-template name="subfieldSelect">
205                                     <xsl:with-param name="codes">av</xsl:with-param>
206                                 </xsl:call-template>
207                             </xsl:with-param>
208                         </xsl:call-template>
209                         </a>
210                     <xsl:text> </xsl:text><xsl:call-template name="part"/>
211             <xsl:choose><xsl:when test="position()=last()"><xsl:text>.</xsl:text></xsl:when><xsl:otherwise><xsl:text>; </xsl:text></xsl:otherwise></xsl:choose>
212         </xsl:for-each>
213
214         <xsl:for-each select="marc:datafield[@tag=490][@ind1=0]">
215              <a href="/cgi-bin/koha/opac-search.pl?q=se:{marc:subfield[@code='a']}">
216                         <xsl:call-template name="chopPunctuation">
217                             <xsl:with-param name="chopString">
218                                 <xsl:call-template name="subfieldSelect">
219                                     <xsl:with-param name="codes">av</xsl:with-param>
220                                 </xsl:call-template>
221                             </xsl:with-param>
222                         </xsl:call-template>
223             </a>
224                     <xsl:call-template name="part"/>
225         <xsl:choose><xsl:when test="position()=last()"><xsl:text>.</xsl:text></xsl:when><xsl:otherwise><xsl:text>; </xsl:text></xsl:otherwise></xsl:choose>
226         </xsl:for-each>
227         </span>
228         </xsl:if>
229
230         <!-- Publisher Statement: Alternate Graphic Representation (MARC 880) -->
231         <xsl:if test="$display880">
232             <xsl:call-template name="m880Select">
233                 <xsl:with-param name="basetags">260</xsl:with-param>
234                 <xsl:with-param name="codes">abcg</xsl:with-param>
235                 <xsl:with-param name="class">results_summary</xsl:with-param>
236                 <xsl:with-param name="label">Publisher: </xsl:with-param>
237             </xsl:call-template>
238         </xsl:if>
239         
240         <xsl:if test="marc:datafield[@tag=260]">
241         <span class="results_summary"><span class="label">Publisher: </span>
242             <xsl:for-each select="marc:datafield[@tag=260]">
243                 <xsl:call-template name="chopPunctuation">
244                   <xsl:with-param name="chopString">
245                     <xsl:call-template name="subfieldSelect">
246                         <xsl:with-param name="codes">bcg</xsl:with-param>
247                     </xsl:call-template>
248                    </xsl:with-param>
249                </xsl:call-template>
250                     <xsl:choose><xsl:when test="position()=last()"><xsl:text>.</xsl:text></xsl:when><xsl:otherwise><xsl:text>; </xsl:text></xsl:otherwise></xsl:choose>
251             </xsl:for-each>
252         </span> 
253         </xsl:if>
254
255         <!-- Edition Statement: Alternate Graphic Representation (MARC 880) -->
256         <xsl:if test="$display880">
257             <xsl:call-template name="m880Select">
258                 <xsl:with-param name="basetags">250</xsl:with-param>
259                 <xsl:with-param name="codes">ab</xsl:with-param>
260                 <xsl:with-param name="class">results_summary</xsl:with-param>
261                 <xsl:with-param name="label">Edition: </xsl:with-param>
262             </xsl:call-template>
263         </xsl:if>
264         
265         <xsl:if test="marc:datafield[@tag=250]">
266         <span class="results_summary"><span class="label">Edition: </span>
267             <xsl:for-each select="marc:datafield[@tag=250]">
268                 <xsl:call-template name="chopPunctuation">
269                   <xsl:with-param name="chopString">
270                     <xsl:call-template name="subfieldSelect">
271                         <xsl:with-param name="codes">ab</xsl:with-param>
272                     </xsl:call-template>
273                    </xsl:with-param>
274                </xsl:call-template>
275                     <xsl:choose><xsl:when test="position()=last()"><xsl:text>.</xsl:text></xsl:when><xsl:otherwise><xsl:text>; </xsl:text></xsl:otherwise></xsl:choose>
276             </xsl:for-each>
277         </span>
278         </xsl:if>
279
280         <!-- Description: Alternate Graphic Representation (MARC 880) -->
281         <xsl:if test="$display880">
282             <xsl:call-template name="m880Select">
283                 <xsl:with-param name="basetags">300</xsl:with-param>
284                 <xsl:with-param name="codes">abceg</xsl:with-param>
285                 <xsl:with-param name="class">results_summary</xsl:with-param>
286                 <xsl:with-param name="label">Description: </xsl:with-param>
287             </xsl:call-template>
288         </xsl:if>
289         
290         <xsl:if test="marc:datafield[@tag=300]">
291         <span class="results_summary"><span class="label">Description: </span>
292             <xsl:for-each select="marc:datafield[@tag=300]">
293                 <xsl:call-template name="chopPunctuation">
294                   <xsl:with-param name="chopString">
295                     <xsl:call-template name="subfieldSelect">
296                         <xsl:with-param name="codes">abceg</xsl:with-param>
297                     </xsl:call-template>
298                    </xsl:with-param>
299                </xsl:call-template>
300                     <xsl:choose><xsl:when test="position()=last()"><xsl:text>.</xsl:text></xsl:when><xsl:otherwise><xsl:text>; </xsl:text></xsl:otherwise></xsl:choose>
301             </xsl:for-each>
302         </span>
303        </xsl:if>
304
305        <abbr class="unapi-id" title="koha:biblionumber:{marc:datafield[@tag=999]/marc:subfield[@code='c']}" ><!-- unAPI --></abbr>
306
307        <xsl:if test="marc:datafield[@tag=020]">
308         <span class="results_summary"><span class="label">ISBN: </span>
309         <xsl:for-each select="marc:datafield[@tag=020]">
310         <xsl:variable name="isbn" select="marc:subfield[@code='a']"/>
311                 <xsl:value-of select="marc:subfield[@code='a']"/>
312                 <xsl:choose><xsl:when test="position()=last()"><xsl:text>.</xsl:text></xsl:when><xsl:otherwise><xsl:text>; </xsl:text></xsl:otherwise></xsl:choose>
313         </xsl:for-each>
314         </span>
315         </xsl:if>
316
317         <xsl:if test="marc:datafield[@tag=022]">
318         <span class="results_summary"><span class="label">ISSN: </span>
319         <xsl:for-each select="marc:datafield[@tag=022]">
320                 <xsl:value-of select="marc:subfield[@code='a']"/>
321                 <xsl:choose><xsl:when test="position()=last()"><xsl:text>.</xsl:text></xsl:when><xsl:otherwise><xsl:text>; </xsl:text></xsl:otherwise></xsl:choose>
322         </xsl:for-each>
323         </span>
324         </xsl:if>
325
326         <!-- Other Title  Statement: Alternate Graphic Representation (MARC 880) -->
327         <xsl:if test="$display880">
328             <xsl:call-template name="m880Select">
329                 <xsl:with-param name="basetags">246</xsl:with-param>
330                 <xsl:with-param name="codes">abhfgnp</xsl:with-param>
331                 <xsl:with-param name="class">results_summary</xsl:with-param>
332                 <xsl:with-param name="label">Other Title: </xsl:with-param>
333             </xsl:call-template>
334         </xsl:if>
335
336         <xsl:if test="marc:datafield[@tag=246]">
337         <span class="results_summary"><span class="label">Other Title: </span>
338             <xsl:for-each select="marc:datafield[@tag=246]">
339                 <xsl:call-template name="chopPunctuation">
340                   <xsl:with-param name="chopString">
341                     <xsl:call-template name="subfieldSelect">
342                         <xsl:with-param name="codes">iabhfgnp</xsl:with-param>
343                     </xsl:call-template>
344                    </xsl:with-param>
345                </xsl:call-template>
346                     <xsl:choose><xsl:when test="position()=last()"><xsl:text>.</xsl:text></xsl:when><xsl:otherwise><xsl:text>; </xsl:text></xsl:otherwise></xsl:choose>
347             </xsl:for-each>
348         </span>
349        </xsl:if>
350
351         <!-- Uniform Title  Statement: Alternate Graphic Representation (MARC 880) -->
352         <xsl:if test="$display880">
353             <xsl:call-template name="m880Select">
354                 <xsl:with-param name="basetags">130,240</xsl:with-param>
355                 <xsl:with-param name="codes">adfklmor</xsl:with-param>
356                 <xsl:with-param name="class">results_summary</xsl:with-param>
357                 <xsl:with-param name="label">Uniform Title: </xsl:with-param>
358             </xsl:call-template>
359         </xsl:if>
360
361         <xsl:if test="marc:datafield[@tag=130]|marc:datafield[@tag=240]|marc:datafield[@tag=730][@ind2!=2]">
362         <span class="results_summary"><span class="label">Uniform titles: </span>
363         <xsl:for-each select="marc:datafield[@tag=130]|marc:datafield[@tag=240]|marc:datafield[@tag=730][@ind2!=2]">
364             <xsl:variable name="str">
365                 <xsl:for-each select="marc:subfield">
366                     <xsl:if test="(contains('adfklmor',@code) and (not(../marc:subfield[@code='n' or @code='p']) or (following-sibling::marc:subfield[@code='n' or @code='p'])))">
367                         <xsl:value-of select="text()"/>
368                         <xsl:text> </xsl:text>
369                      </xsl:if>
370                 </xsl:for-each>
371             </xsl:variable>
372             <xsl:call-template name="chopPunctuation">
373                 <xsl:with-param name="chopString">
374                     <xsl:value-of select="substring($str,1,string-length($str)-1)"/>
375                         
376                 </xsl:with-param>
377             </xsl:call-template>
378             <xsl:choose><xsl:when test="position()=last()"><xsl:text>.</xsl:text></xsl:when><xsl:otherwise><xsl:text>; </xsl:text></xsl:otherwise></xsl:choose>
379         </xsl:for-each>
380         </span>
381         </xsl:if>
382
383         <xsl:if test="marc:datafield[substring(@tag, 1, 1) = '6']">
384             <span class="results_summary"><span class="label">Related Subjects: </span>
385             <xsl:for-each select="marc:datafield[substring(@tag, 1, 1) = '6']">
386             <a>
387             <xsl:choose>
388             <xsl:when test="marc:subfield[@code=9]">
389                 <xsl:attribute name="href">/cgi-bin/koha/opac-search.pl?q=an:<xsl:value-of select="marc:subfield[@code=9]"/></xsl:attribute>
390             </xsl:when>
391             <xsl:otherwise>
392                 <xsl:attribute name="href">/cgi-bin/koha/opac-search.pl?q=su:<xsl:value-of select="marc:subfield[@code='a']"/></xsl:attribute>
393             </xsl:otherwise>
394             </xsl:choose>
395             <xsl:call-template name="chopPunctuation">
396                 <xsl:with-param name="chopString">
397                     <xsl:call-template name="subfieldSelect">
398                         <xsl:with-param name="codes">abcdvxyz</xsl:with-param>
399                         <xsl:with-param name="subdivCodes">vxyz</xsl:with-param>
400                         <xsl:with-param name="subdivDelimiter">-- </xsl:with-param>
401                     </xsl:call-template>
402                 </xsl:with-param>
403             </xsl:call-template>
404             </a>
405             <xsl:choose>
406             <xsl:when test="position()=last()"></xsl:when>
407             <xsl:otherwise> | </xsl:otherwise>
408             </xsl:choose>
409
410             </xsl:for-each>
411             </span>
412         </xsl:if>
413
414         <xsl:if test="marc:datafield[@tag=856]">
415         <span class="results_summary"><span class="label">Online Resources: </span>
416         <xsl:for-each select="marc:datafield[@tag=856]">
417                             <xsl:if test="$OPACURLOpenInNewWindow='0'">
418                                    <a><xsl:attribute name="href"><xsl:value-of select="marc:subfield[@code='u']"/></xsl:attribute>
419                                     <xsl:choose>
420                                     <xsl:when test="marc:subfield[@code='y' or @code='3' or @code='z']">
421                                         <xsl:call-template name="subfieldSelect">
422                                         <xsl:with-param name="codes">y3z</xsl:with-param>
423                                         </xsl:call-template>
424                                     </xsl:when>
425                                     <xsl:when test="not(marc:subfield[@code='y']) and not(marc:subfield[@code='3']) and not(marc:subfield[@code='z'])">
426                                         <xsl:choose>
427                                         <xsl:when test="$URLLinkText!=''">
428                                                 <xsl:value-of select="$URLLinkText"/>
429                                         </xsl:when>
430                                         <xsl:otherwise>
431                                                 <xsl:text>Click here to access online</xsl:text>
432                                         </xsl:otherwise>
433                                         </xsl:choose>
434                                     </xsl:when>
435                                     </xsl:choose>
436                                     </a>
437                               </xsl:if>
438                             <xsl:if test="$OPACURLOpenInNewWindow='1'">
439                                    <a target='_blank'><xsl:attribute name="href"><xsl:value-of select="marc:subfield[@code='u']"/></xsl:attribute>
440                                     <xsl:choose>
441                                     <xsl:when test="marc:subfield[@code='y' or @code='3' or @code='z']">
442                                         <xsl:call-template name="subfieldSelect">
443                                         <xsl:with-param name="codes">y3z</xsl:with-param>
444                                         </xsl:call-template>
445                                     </xsl:when>
446                                     <xsl:when test="not(marc:subfield[@code='y']) and not(marc:subfield[@code='3']) and not(marc:subfield[@code='z'])">
447                                         <xsl:choose>
448                                         <xsl:when test="$URLLinkText!=''">
449                                                 <xsl:value-of select="$URLLinkText"/>
450                                         </xsl:when>
451                                         <xsl:otherwise>
452                                                 <xsl:text>Click here to access online</xsl:text>
453                                         </xsl:otherwise>
454                                         </xsl:choose>
455                                     </xsl:when>
456                                     </xsl:choose>
457                                     </a>
458                               </xsl:if>
459                                     <xsl:choose>
460                                     <xsl:when test="position()=last()"><xsl:text>  </xsl:text></xsl:when>
461                                     <xsl:otherwise> | </xsl:otherwise>
462                                     </xsl:choose>
463
464         </xsl:for-each>
465         </span>
466         </xsl:if>
467         <xsl:if test="marc:datafield[@tag=505]">
468         <xsl:for-each select="marc:datafield[@tag=505]">
469         <span class="results_summary"><span class="label">
470         <xsl:choose>
471         <xsl:when test="@ind1=0">
472             Contents:
473         </xsl:when>
474         <xsl:when test="@ind1=1">
475             Incomplete contents:
476         </xsl:when>
477         <xsl:when test="@ind1=1">
478             Partial contents:
479         </xsl:when>
480         </xsl:choose>  
481         </span>
482         <xsl:choose>
483         <xsl:when test="@ind2=0">
484             <xsl:for-each select="marc:subfield[@code='t']">
485                 <xsl:value-of select="marc:subfield[@code=t]"/> <xsl:value-of select="marc:subfield[@code=r]"/>
486             </xsl:for-each> 
487         </xsl:when>
488         <xsl:otherwise>
489             <xsl:call-template name="subfieldSelect">
490                 <xsl:with-param name="codes">au</xsl:with-param>
491             </xsl:call-template>
492         </xsl:otherwise>
493         </xsl:choose>
494         </span>
495         </xsl:for-each>
496         </xsl:if>
497
498         <!-- 773 -->
499         <xsl:if test="marc:datafield[@tag=773]">
500         <xsl:for-each select="marc:datafield[@tag=773]">
501         <xsl:if test="@ind1=0">
502         <span class="results_summary"><span class="label">
503         <xsl:choose>
504         <xsl:when test="@ind2=' '">
505             In:
506         </xsl:when>
507         <xsl:when test="@ind2=8">
508             <xsl:if test="marc:subfield[@code='i']">
509                 <xsl:value-of select="marc:subfield[@code='i']"/>
510             </xsl:if>
511         </xsl:when>
512         </xsl:choose>
513         </span>
514                 <xsl:variable name="f773">
515                     <xsl:call-template name="subfieldSelect">
516                         <xsl:with-param name="codes">at</xsl:with-param>
517                     </xsl:call-template>
518                 </xsl:variable>
519              <a><xsl:attribute name="href">/cgi-bin/koha/opac-search.pl?q=<xsl:value-of select="translate($f773, '()', '')"/></xsl:attribute>
520                 <xsl:value-of select="translate($f773, '()', '')"/>
521             </a>
522         </span>
523  
524             <span class="results_summary"><xsl:value-of select="marc:subfield[@code='n']"/></span>
525
526         </xsl:if>
527         </xsl:for-each>
528         </xsl:if>
529
530         <!-- 780 -->
531         <xsl:if test="marc:datafield[@tag=780]">
532         <xsl:for-each select="marc:datafield[@tag=780]">
533         <xsl:if test="@ind1=0">
534         <span class="results_summary"><span class="label">
535         <xsl:choose>
536         <xsl:when test="@ind2=0">
537             Continues:
538         </xsl:when>
539         <xsl:when test="@ind2=1">
540             Continues in part:
541         </xsl:when>
542         <xsl:when test="@ind2=2">
543             Supersedes:
544         </xsl:when>
545         <xsl:when test="@ind2=3">
546             Supersedes in part:
547         </xsl:when>
548         <xsl:when test="@ind2=4">
549             Formed by the union: ... and: ...
550         </xsl:when>
551         <xsl:when test="@ind2=5">
552             Absorbed:
553         </xsl:when>
554         <xsl:when test="@ind2=6">
555             Absorbed in part:
556         </xsl:when>
557         <xsl:when test="@ind2=7">
558             Separated from:
559         </xsl:when>
560         </xsl:choose>
561         </span>
562                 <xsl:variable name="f780">
563                     <xsl:call-template name="subfieldSelect">
564                         <xsl:with-param name="codes">at</xsl:with-param>
565                     </xsl:call-template>
566                 </xsl:variable>
567              <a><xsl:attribute name="href">/cgi-bin/koha/opac-search.pl?q=<xsl:value-of select="translate($f780, '()', '')"/></xsl:attribute>
568                 <xsl:value-of select="translate($f780, '()', '')"/>
569             </a>
570         </span>
571  
572         <span class="results_summary"><xsl:value-of select="marc:subfield[@code='n']"/></span>
573
574         </xsl:if>
575         </xsl:for-each>
576         </xsl:if>
577
578         <!-- 785 -->
579         <xsl:if test="marc:datafield[@tag=785]">
580         <xsl:for-each select="marc:datafield[@tag=785]">
581         <xsl:if test="@ind1=0">
582         <span class="results_summary"><span class="label">
583         <xsl:choose>
584         <xsl:when test="@ind2=0">
585             Continued by:
586         </xsl:when>
587         <xsl:when test="@ind2=1">
588             Continued in part by:
589         </xsl:when>
590         <xsl:when test="@ind2=2">
591             Superseded by:
592         </xsl:when>
593         <xsl:when test="@ind2=3">
594             Superseded in part by:
595         </xsl:when>
596         <xsl:when test="@ind2=4">
597             Absorbed by:
598         </xsl:when>
599         <xsl:when test="@ind2=5">
600             Absorbed in part by:
601         </xsl:when>
602         <xsl:when test="@ind2=6">
603             Split into .. and ...:
604         </xsl:when>
605         <xsl:when test="@ind2=7">
606             Merged with ... to form ...
607         </xsl:when>
608         <xsl:when test="@ind2=8">
609             Changed back to:
610         </xsl:when>
611
612         </xsl:choose>
613         </span>
614                    <xsl:variable name="f785">
615                     <xsl:call-template name="subfieldSelect">
616                         <xsl:with-param name="codes">at</xsl:with-param>
617                     </xsl:call-template>
618                 </xsl:variable>
619
620                 <a><xsl:attribute name="href">/cgi-bin/koha/opac-search.pl?q=<xsl:value-of select="translate($f785, '()', '')"/></xsl:attribute>
621                 <xsl:value-of select="translate($f785, '()', '')"/>
622             </a>
623
624         </span>
625         </xsl:if>
626         </xsl:for-each>
627         </xsl:if>
628
629     </xsl:template>
630
631     <xsl:template name="nameABCDQ">
632             <xsl:call-template name="chopPunctuation">
633                 <xsl:with-param name="chopString">
634                     <xsl:call-template name="subfieldSelect">
635                         <xsl:with-param name="codes">aq</xsl:with-param>
636                     </xsl:call-template>
637                 </xsl:with-param>
638                 <xsl:with-param name="punctuation">
639                     <xsl:text>:,;/ </xsl:text>
640                 </xsl:with-param>
641             </xsl:call-template>
642         <xsl:call-template name="termsOfAddress"/>
643     </xsl:template>
644
645     <xsl:template name="nameABCDN">
646         <xsl:for-each select="marc:subfield[@code='a']">
647                 <xsl:call-template name="chopPunctuation">
648                     <xsl:with-param name="chopString" select="."/>
649                 </xsl:call-template>
650         </xsl:for-each>
651         <xsl:for-each select="marc:subfield[@code='b']">
652                 <xsl:value-of select="."/>
653         </xsl:for-each>
654         <xsl:if test="marc:subfield[@code='c'] or marc:subfield[@code='d'] or marc:subfield[@code='n']">
655                 <xsl:call-template name="subfieldSelect">
656                     <xsl:with-param name="codes">cdn</xsl:with-param>
657                 </xsl:call-template>
658         </xsl:if>
659     </xsl:template>
660
661     <xsl:template name="nameACDEQ">
662             <xsl:call-template name="subfieldSelect">
663                 <xsl:with-param name="codes">acdeq</xsl:with-param>
664             </xsl:call-template>
665     </xsl:template>
666     <xsl:template name="termsOfAddress">
667         <xsl:if test="marc:subfield[@code='b' or @code='c']">
668             <xsl:call-template name="chopPunctuation">
669                 <xsl:with-param name="chopString">
670                     <xsl:call-template name="subfieldSelect">
671                         <xsl:with-param name="codes">bc</xsl:with-param>
672                     </xsl:call-template>
673                 </xsl:with-param>
674             </xsl:call-template>
675         </xsl:if>
676     </xsl:template>
677
678     <xsl:template name="part">
679         <xsl:variable name="partNumber">
680             <xsl:call-template name="specialSubfieldSelect">
681                 <xsl:with-param name="axis">n</xsl:with-param>
682                 <xsl:with-param name="anyCodes">n</xsl:with-param>
683                 <xsl:with-param name="afterCodes">fghkdlmor</xsl:with-param>
684             </xsl:call-template>
685         </xsl:variable>
686         <xsl:variable name="partName">
687             <xsl:call-template name="specialSubfieldSelect">
688                 <xsl:with-param name="axis">p</xsl:with-param>
689                 <xsl:with-param name="anyCodes">p</xsl:with-param>
690                 <xsl:with-param name="afterCodes">fghkdlmor</xsl:with-param>
691             </xsl:call-template>
692         </xsl:variable>
693         <xsl:if test="string-length(normalize-space($partNumber))">
694                 <xsl:call-template name="chopPunctuation">
695                     <xsl:with-param name="chopString" select="$partNumber"/>
696                 </xsl:call-template>
697         </xsl:if>
698         <xsl:if test="string-length(normalize-space($partName))">
699                 <xsl:call-template name="chopPunctuation">
700                     <xsl:with-param name="chopString" select="$partName"/>
701                 </xsl:call-template>
702         </xsl:if>
703     </xsl:template>
704
705     <xsl:template name="specialSubfieldSelect">
706         <xsl:param name="anyCodes"/>
707         <xsl:param name="axis"/>
708         <xsl:param name="beforeCodes"/>
709         <xsl:param name="afterCodes"/>
710         <xsl:variable name="str">
711             <xsl:for-each select="marc:subfield">
712                 <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])">
713                     <xsl:value-of select="text()"/>
714                     <xsl:text> </xsl:text>
715                 </xsl:if>
716             </xsl:for-each>
717         </xsl:variable>
718         <xsl:value-of select="substring($str,1,string-length($str)-1)"/>
719     </xsl:template>
720 </xsl:stylesheet>