Bug 31106: Fix links generated in XSLTs
[koha.git] / koha-tmpl / opac-tmpl / bootstrap / en / xslt / MARC21slimUtils.xsl
1 <?xml version='1.0'?>
2 <!DOCTYPE stylesheet>
3 <xsl:stylesheet version="1.0"
4   xmlns:marc="http://www.loc.gov/MARC21/slim"
5   xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
6   xmlns:str="http://exslt.org/strings"
7   exclude-result-prefixes="marc str">
8   <xsl:include href="MARC21Languages.xsl"/>
9         <xsl:template name="datafield">
10                 <xsl:param name="tag"/>
11                 <xsl:param name="ind1"><xsl:text> </xsl:text></xsl:param>
12                 <xsl:param name="ind2"><xsl:text> </xsl:text></xsl:param>
13                 <xsl:param name="subfields"/>
14                 <xsl:element name="datafield">
15                         <xsl:attribute name="tag">
16                                 <xsl:value-of select="$tag"/>
17                         </xsl:attribute>
18                         <xsl:attribute name="ind1">
19                                 <xsl:value-of select="$ind1"/>
20                         </xsl:attribute>
21                         <xsl:attribute name="ind2">
22                                 <xsl:value-of select="$ind2"/>
23                         </xsl:attribute>
24                         <xsl:copy-of select="$subfields"/>
25                 </xsl:element>
26         </xsl:template>
27
28         <xsl:template name="subfieldSelect">
29                 <xsl:param name="codes"/>
30                 <xsl:param name="delimeter"><xsl:text> </xsl:text></xsl:param>
31                 <xsl:param name="subdivCodes"/>
32                 <xsl:param name="subdivDelimiter"/>
33         <xsl:param name="prefix"/>
34         <xsl:param name="suffix"/>
35         <xsl:param name="urlencode"/>
36                 <xsl:variable name="str">
37                         <xsl:for-each select="marc:subfield">
38                                 <xsl:if test="contains($codes, @code)">
39                     <xsl:if test="contains($subdivCodes, @code)">
40                         <xsl:value-of select="$subdivDelimiter"/>
41                     </xsl:if>
42                                         <xsl:value-of select="$prefix"/><xsl:value-of select="text()"/><xsl:value-of select="$suffix"/><xsl:value-of select="$delimeter"/>
43                                 </xsl:if>
44                         </xsl:for-each>
45                 </xsl:variable>
46         <xsl:choose>
47             <xsl:when test="$urlencode=1">
48                 <xsl:value-of select="str:encode-uri(substring($str,1,string-length($str)-string-length($delimeter)), true())"/>
49             </xsl:when>
50             <xsl:otherwise>
51                 <xsl:value-of select="substring($str,1,string-length($str)-string-length($delimeter))"/>
52             </xsl:otherwise>
53         </xsl:choose>
54         </xsl:template>
55
56     <xsl:template name="subfieldSelectSpan">
57         <xsl:param name="codes"/>
58         <xsl:param name="delimeter"><xsl:text> </xsl:text></xsl:param>
59         <xsl:param name="subdivCodes"/>
60         <xsl:param name="subdivDelimiter"/>
61         <xsl:param name="prefix"/>
62         <xsl:param name="suffix"/>
63         <xsl:param name="newline"/>
64             <xsl:for-each select="marc:subfield">
65                 <xsl:if test="contains($codes, @code)">
66                     <span>
67                         <xsl:attribute name="class">
68                             <xsl:value-of select="@code"/>
69                             <xsl:if test="$newline = 1 and contains(text(), '--')">
70                                 <xsl:text> newline</xsl:text>
71                             </xsl:if>
72                         </xsl:attribute>
73                         <xsl:if test="contains($subdivCodes, @code)">
74                             <xsl:value-of select="$subdivDelimiter"/>
75                         </xsl:if>
76                         <xsl:value-of select="$prefix"/><xsl:value-of select="text()"/><xsl:value-of select="$suffix"/><xsl:if test="position()!=last()"><xsl:value-of select="$delimeter"/></xsl:if>
77                     </span>
78                 </xsl:if>
79             </xsl:for-each>
80     </xsl:template>
81
82         <xsl:template name="buildSpaces">
83                 <xsl:param name="spaces"/>
84                 <xsl:param name="char"><xsl:text> </xsl:text></xsl:param>
85                 <xsl:if test="$spaces>0">
86                         <xsl:value-of select="$char"/>
87                         <xsl:call-template name="buildSpaces">
88                                 <xsl:with-param name="spaces" select="$spaces - 1"/>
89                                 <xsl:with-param name="char" select="$char"/>
90                         </xsl:call-template>
91                 </xsl:if>
92         </xsl:template>
93
94   <xsl:template name="buildBiblioDefaultViewURL">
95     <xsl:param name="BiblioDefaultView"/>
96     <xsl:choose>
97         <xsl:when test="$BiblioDefaultView='normal'">
98             <xsl:text>/cgi-bin/koha/opac-detail.pl?biblionumber=</xsl:text>
99         </xsl:when>
100         <xsl:when test="$BiblioDefaultView='isbd'">
101             <xsl:text>/cgi-bin/koha/opac-ISBDdetail.pl?biblionumber=</xsl:text>
102         </xsl:when>
103         <xsl:when test="$BiblioDefaultView='marc'">
104             <xsl:text>/cgi-bin/koha/opac-MARCdetail.pl?biblionumber=</xsl:text>
105         </xsl:when>
106         <xsl:otherwise>
107             <xsl:text>/cgi-bin/koha/opac-detail.pl?biblionumber=</xsl:text>
108         </xsl:otherwise>
109     </xsl:choose>
110   </xsl:template>
111
112         <xsl:template name="chopPunctuation">
113                 <xsl:param name="chopString"/>
114                 <xsl:variable name="length" select="string-length($chopString)"/>
115                 <xsl:choose>
116                         <xsl:when test="$length=0"/>
117                         <xsl:when test="contains('.:,;/ ', substring($chopString,$length,1))">
118                                 <xsl:call-template name="chopPunctuation">
119                                         <xsl:with-param name="chopString" select="substring($chopString,1,$length - 1)"/>
120                                 </xsl:call-template>
121                         </xsl:when>
122                         <xsl:when test="not($chopString)"/>
123                         <xsl:otherwise><xsl:value-of select="$chopString"/></xsl:otherwise>
124                 </xsl:choose>
125         </xsl:template>
126
127         <!-- Function extractControlNumber is used to extract the control number (record number) from MARC tags 773/80/85 [etc.] subfield $w.
128              Parameter: control number string.
129              Assumes LOC convention: (OrgCode)recordNumber.
130              If OrgCode is not present, return full string.
131              Additionally, handle various brackets/parentheses. Chop leading and trailing spaces.
132          Returns the value URI-encoded.
133         -->
134         <xsl:template name="extractControlNumber">
135             <xsl:param name="subfieldW"/>
136             <xsl:variable name="tranW" select="translate($subfieldW,']})&gt;','))))')"/>
137             <xsl:choose>
138               <xsl:when test="contains($tranW,')')">
139                 <xsl:value-of select="str:encode-uri(normalize-space(translate(substring-after($tranW,')'),'[]{}()&lt;&gt;','')), true())"/>
140               </xsl:when>
141               <xsl:otherwise>
142                 <xsl:value-of select="str:encode-uri(normalize-space($subfieldW), true())"/>
143               </xsl:otherwise>
144             </xsl:choose>
145         </xsl:template>
146
147     <!-- Function m880Select:  Display Alternate Graphic Representation (MARC 880) for selected latin "base"tags
148         - should be called immediately before the corresonding latin tags are processed
149         - tags in right-to-left languages are displayed floating right
150         * Parameter:
151            + basetags: display these tags if found in linkage section ( subfield 6) of tag 880
152            + codes: display these subfields codes
153         * Options:
154             - class: wrap output in <span class="$class">...</span>
155             - label: prefix each(!) tag with label $label
156             - bibno: link to biblionumber $bibno
157             - index: build a search link using index $index with subfield $a as key; if subfield $9 is present use index 'an' with key $9 instead.
158          * Limitations:
159             - displays every field on a separate line (to switch between rtl and ltr)
160          * Pitfalls:
161            (!) output might be empty
162     -->
163     <xsl:template name="m880Select">
164          <xsl:param name="basetags"/> <!-- e.g.  100,700,110,710 -->
165         <xsl:param name="codes"/> <!-- e.g. abc  -->
166         <xsl:param name="class"/> <!-- e.g. results_summary -->
167         <xsl:param name="label"/> <!-- e.g.  Edition -->
168         <xsl:param name="bibno"/>
169         <xsl:param name="index"/> <!-- e.g.  au -->
170
171         <xsl:for-each select="marc:datafield[@tag=880]">
172             <xsl:variable name="code6" select="marc:subfield[@code=6]"/>
173             <xsl:if test="contains(string($basetags), substring($code6,1,3))">
174                 <span>
175                     <xsl:choose>
176                     <xsl:when test="boolean($class) and substring($code6,string-length($code6)-1,2) ='/r'">
177                         <xsl:attribute name="class"><xsl:value-of select="$class"/> m880</xsl:attribute>
178                         <xsl:attribute name="dir">rtl</xsl:attribute>
179                     </xsl:when>
180                      <xsl:when test="boolean($class)">
181                         <xsl:attribute name="class"><xsl:value-of select="$class"/></xsl:attribute>
182                         <xsl:attribute name="style">display:block; </xsl:attribute>
183                     </xsl:when>
184                      <xsl:when test="substring($code6,string-length($code6)-1,2) ='/r'">
185                         <xsl:attribute name="class"><xsl:value-of select="$class"/> m880</xsl:attribute>
186                     </xsl:when>
187                     </xsl:choose>
188                     <xsl:if test="boolean($label)">
189                         <span class="label">
190                             <xsl:value-of select="$label"/>
191                         </span>
192                     </xsl:if>
193                     <xsl:variable name="str">
194                         <xsl:for-each select="marc:subfield">
195                             <xsl:if test="contains($codes, @code)">
196                                 <xsl:value-of select="text()"/>
197                                 <xsl:text> </xsl:text>
198                             </xsl:if>
199                         </xsl:for-each>
200                     </xsl:variable>
201                     <xsl:if test="string-length($str) &gt; 0">
202                         <xsl:choose>
203                             <xsl:when test="boolean($bibno)">
204                                 <a>
205                                     <xsl:attribute name="href">/cgi-bin/koha/opac-detail.pl?biblionumber=<xsl:value-of  select="str:encode-uri($bibno, true())"/></xsl:attribute>
206                                     <xsl:value-of select="$str"/>
207                                 </a>
208                             </xsl:when>
209                            <xsl:when test="boolean($index) and boolean(marc:subfield[@code=9])">
210                                 <a>
211                                     <xsl:attribute name="href">/cgi-bin/koha/opac-search.pl?q=an:<xsl:value-of  select="str:encode-uri(marc:subfield[@code=9], true())"/></xsl:attribute>
212                                     <xsl:value-of select="$str"/>
213                                 </a>
214                             </xsl:when>
215                             <xsl:when test="boolean($index)">
216                                 <a>
217                                     <xsl:attribute name="href">/cgi-bin/koha/opac-search.pl?q=<xsl:value-of select="str:encode-uri($index, true())"/>:<xsl:value-of select="str:encode-uri(marc:subfield[@code='a'], true())"/></xsl:attribute>
218                                     <xsl:value-of select="$str"/>
219                                 </a>
220                             </xsl:when>
221                             <xsl:otherwise>
222                                 <xsl:value-of select="$str"/>
223                             </xsl:otherwise>
224                         </xsl:choose>
225                     </xsl:if>
226                 </span>
227             </xsl:if>
228         </xsl:for-each>
229     </xsl:template>
230
231     <xsl:template name="showRDAtag264">
232         <!-- Function showRDAtag264 shows selected information from tag 264
233          on the Publisher line (used by OPAC Detail and Results)
234          Depending on how many tags you have, we will pick by preference
235          Publisher-latest or Publisher or 'Other'-latest or 'Other'
236          The preferred tag is saved in the fav variable and passed to a
237          helper named-template -->
238         <!-- Amended  to show all 264 fields (filtered by ind1=3 if ind1=3 is present in the record)  -->
239         <xsl:param name="show_url"/>
240         <xsl:choose>
241             <xsl:when test="marc:datafield[@tag=264 and @ind1=3]">
242                 <xsl:for-each select="marc:datafield[@tag=264 and @ind1=3]">
243                     <xsl:call-template name="showRDAtag264helper">
244                         <xsl:with-param name="field" select="."/>
245                         <xsl:with-param name="url" select="$show_url"/>
246                     </xsl:call-template>
247                 </xsl:for-each>
248             </xsl:when>
249             <xsl:otherwise>
250                 <xsl:for-each select="marc:datafield[@tag=264]">
251                     <xsl:call-template name="showRDAtag264helper">
252                         <xsl:with-param name="field" select="."/>
253                         <xsl:with-param name="url" select="$show_url"/>
254                     </xsl:call-template>
255                 </xsl:for-each>
256             </xsl:otherwise>
257         </xsl:choose>
258     </xsl:template>
259     <xsl:template name="showRDAtag264helper">
260         <xsl:param name="field"/>
261         <xsl:param name="url"/>
262         <xsl:variable name="ind2" select="$field/@ind2"/>
263         <span class="results_summary rda264">
264             <xsl:choose>
265                 <xsl:when test="$ind2='0'">
266                     <span class="label">Producer: </span>
267                 </xsl:when>
268                 <xsl:when test="$ind2='1'">
269                     <span class="label">Publisher: </span>
270                 </xsl:when>
271                 <xsl:when test="$ind2='2'">
272                     <span class="label">Distributor: </span>
273                 </xsl:when>
274                 <xsl:when test="$ind2='3'">
275                     <span class="label">Manufacturer: </span>
276                 </xsl:when>
277                 <xsl:when test="$ind2='4'">
278                     <span class="label">Copyright date: </span>
279                 </xsl:when>
280             </xsl:choose>
281
282             <xsl:if test="$field/marc:subfield[@code='a']">
283                 <xsl:call-template name="subfieldSelect">
284                     <xsl:with-param name="codes">a</xsl:with-param>
285                 </xsl:call-template>
286             </xsl:if>
287             <xsl:text> </xsl:text>
288
289             <xsl:choose>
290                 <xsl:when test="$url='1'">
291                     <xsl:if test="$field/marc:subfield[@code='b']">
292                          <a>
293                          <xsl:attribute name="href">/cgi-bin/koha/opac-search.pl?q=Provider:<xsl:value-of select="str:encode-uri($field/marc:subfield[@code='b'], true())"/></xsl:attribute>
294                          <xsl:call-template name="subfieldSelect">
295                              <xsl:with-param name="codes">b</xsl:with-param>
296                          </xsl:call-template>
297                          </a>
298                     </xsl:if>
299                 </xsl:when>
300                 <xsl:otherwise>
301                     <xsl:if test="$field/marc:subfield[@code='b']">
302                         <xsl:call-template name="subfieldSelect">
303                             <xsl:with-param name="codes">b</xsl:with-param>
304                         </xsl:call-template>
305                     </xsl:if>
306                 </xsl:otherwise>
307             </xsl:choose>
308             <xsl:text> </xsl:text>
309             <xsl:call-template name="chopPunctuation">
310                 <xsl:with-param name="chopString">
311                     <xsl:call-template name="subfieldSelect">
312                         <xsl:with-param name="codes">c</xsl:with-param>
313                     </xsl:call-template>
314                 </xsl:with-param>
315             </xsl:call-template>
316         </span>
317     </xsl:template>
318
319     <xsl:template name="show-lang-041">
320       <xsl:if test="marc:datafield[@tag=041]">
321     <xsl:for-each select="marc:datafield[@tag=041]">
322         <span class="results_summary languages">
323         <xsl:call-template name="show-lang-node">
324             <xsl:with-param name="langNode" select="marc:subfield[@code='a']"/>
325             <xsl:with-param name="langLabel">Language: </xsl:with-param>
326         </xsl:call-template>
327         <xsl:call-template name="show-lang-node">
328             <xsl:with-param name="langNode" select="marc:subfield[@code='b']"/>
329             <xsl:with-param name="langLabel">Summary language: </xsl:with-param>
330         </xsl:call-template>
331         <xsl:call-template name="show-lang-node">
332             <xsl:with-param name="langNode" select="marc:subfield[@code='d']"/>
333             <xsl:with-param name="langLabel">Spoken language: </xsl:with-param>
334         </xsl:call-template>
335         <xsl:call-template name="show-lang-node">
336             <xsl:with-param name="langNode" select="marc:subfield[@code='h']"/>
337             <xsl:with-param name="langLabel">Original language: </xsl:with-param>
338         </xsl:call-template>
339         <xsl:call-template name="show-lang-node">
340             <xsl:with-param name="langNode" select="marc:subfield[@code='j']"/>
341             <xsl:with-param name="langLabel">Subtitle language: </xsl:with-param>
342         </xsl:call-template>
343         </span>
344     </xsl:for-each>
345       </xsl:if>
346     </xsl:template>
347
348     <xsl:template name="show-lang-node">
349       <xsl:param name="langNode"/>
350       <xsl:param name="langLabel"/>
351       <xsl:if test="$langNode">
352     <span class="language">
353         <span class="label"><xsl:value-of select="$langLabel"/></span>
354         <xsl:for-each select="$langNode">
355         <span>
356             <xsl:attribute name="class">lang_code-<xsl:value-of select="translate(., ' .-;|#', '_')"/></xsl:attribute>
357             <xsl:call-template name="languageCodeText">
358         <xsl:with-param name="code" select="."/>
359             </xsl:call-template>
360             <xsl:if test="position() != last()">
361             <span class="separator"><xsl:text>, </xsl:text></span>
362             </xsl:if>
363         </span>
364         </xsl:for-each>
365         <span class="separator"><xsl:text> </xsl:text></span>
366     </span>
367       </xsl:if>
368     </xsl:template>
369
370     <xsl:template name="show-series">
371         <xsl:param name="searchurl"/>
372         <xsl:param name="UseControlNumber"/>
373         <xsl:param name="UseAuthoritiesForTracings"/>
374         <!-- Series -->
375         <xsl:if test="marc:datafield[@tag=440 or @tag=490]">
376         <span class="results_summary series"><span class="label">Series: </span>
377         <!-- 440 -->
378         <xsl:for-each select="marc:datafield[@tag=440]">
379             <a><xsl:attribute name="href"><xsl:value-of select="$searchurl"/>?q=se,phr:"<xsl:value-of select="str:encode-uri(marc:subfield[@code='a'], true())"/>"</xsl:attribute>
380                 <xsl:call-template name="chopPunctuation">
381                     <xsl:with-param name="chopString">
382                         <xsl:call-template name="subfieldSelect">
383                             <xsl:with-param name="codes">a</xsl:with-param>
384                         </xsl:call-template>
385                     </xsl:with-param>
386                 </xsl:call-template>
387             </a>
388             <xsl:call-template name="part"/>
389             <xsl:if test="marc:subfield[@code='v']">
390                 <xsl:text> ; </xsl:text><xsl:value-of select="marc:subfield[@code='v']" />
391             </xsl:if>
392             <xsl:choose>
393                 <xsl:when test="position()=last()">
394                     <xsl:if test="../marc:datafield[@tag=490][@ind1!=1]">
395                         <span class="separator"> | </span>
396                     </xsl:if>
397                 </xsl:when>
398                 <xsl:otherwise><span class="separator"> | </span></xsl:otherwise>
399             </xsl:choose>
400         </xsl:for-each>
401
402         <!-- 490 Series not traced, Ind1 = 0 -->
403         <xsl:for-each select="marc:datafield[@tag=490][@ind1!=1]">
404             <a><xsl:attribute name="href"><xsl:value-of select="$searchurl"/>?q=se,phr:"<xsl:value-of select="str:encode-uri(marc:subfield[@code='a'], true())"/>"</xsl:attribute>
405                         <xsl:call-template name="chopPunctuation">
406                             <xsl:with-param name="chopString">
407                                 <xsl:call-template name="subfieldSelect">
408                                     <xsl:with-param name="codes">a</xsl:with-param>
409                                 </xsl:call-template>
410                             </xsl:with-param>
411                         </xsl:call-template>
412             </a>
413             <xsl:call-template name="part"/>
414             <xsl:if test="marc:subfield[@code='v']">
415                 <xsl:text> ; </xsl:text><xsl:value-of select="marc:subfield[@code='v']" />
416             </xsl:if>
417             <xsl:choose>
418                 <xsl:when test="position()=last()">
419                     <xsl:if test="../marc:datafield[@tag=490][@ind1=1]">
420                         <span class="separator"> | </span>
421                     </xsl:if>
422                 </xsl:when>
423                 <xsl:otherwise><span class="separator"> | </span></xsl:otherwise>
424             </xsl:choose>
425         </xsl:for-each>
426         <!-- 490 Series traced, Ind1 = 1 -->
427         <xsl:if test="marc:datafield[@tag=490][@ind1=1]">
428             <xsl:for-each select="marc:datafield[@tag=800 or @tag=810 or @tag=811]">
429                 <xsl:choose>
430                     <xsl:when test="$UseControlNumber = '1' and marc:subfield[@code='w']">
431                         <a><xsl:attribute name="href"><xsl:value-of select="$searchurl"/>?q=rcn:<xsl:value-of select="str:encode-uri(marc:subfield[@code='w'], true())"/></xsl:attribute>
432                             <xsl:call-template name="chopPunctuation">
433                                 <xsl:with-param name="chopString">
434                                     <xsl:call-template name="subfieldSelect">
435                                         <xsl:with-param name="codes">a_t</xsl:with-param>
436                                     </xsl:call-template>
437                                 </xsl:with-param>
438                             </xsl:call-template>
439                         </a>
440                     </xsl:when>
441                     <xsl:when test="marc:subfield[@code=9] and $UseAuthoritiesForTracings='1'">
442                         <a><xsl:attribute name="href"><xsl:value-of select="$searchurl"/>?q=an:<xsl:value-of select="str:encode-uri(marc:subfield[@code=9], true())"/></xsl:attribute>
443                             <xsl:call-template name="chopPunctuation">
444                                 <xsl:with-param name="chopString">
445                                     <xsl:call-template name="subfieldSelect">
446                                         <xsl:with-param name="codes">a_t</xsl:with-param>
447                                     </xsl:call-template>
448                                 </xsl:with-param>
449                             </xsl:call-template>
450                         </a>
451                     </xsl:when>
452                     <xsl:otherwise>
453                         <a><xsl:attribute name="href"><xsl:value-of select="$searchurl"/>?q=se,phr:"<xsl:value-of select="str:encode-uri(marc:subfield[@code='t'], true())"/>"&amp;q=au:"<xsl:value-of select="str:encode-uri(marc:subfield[@code='a'], true())"/>"</xsl:attribute>
454                             <xsl:call-template name="chopPunctuation">
455                                 <xsl:with-param name="chopString">
456                                     <xsl:call-template name="subfieldSelect">
457                                         <xsl:with-param name="codes">a_t</xsl:with-param>
458                                     </xsl:call-template>
459                                 </xsl:with-param>
460                             </xsl:call-template>
461                         </a>
462                     </xsl:otherwise>
463                 </xsl:choose>
464                 <xsl:call-template name="part"/>
465                 <xsl:text> ; </xsl:text>
466                 <xsl:value-of  select="marc:subfield[@code='v']" />
467             <xsl:choose><xsl:when test="position()=last()"><xsl:text></xsl:text></xsl:when><xsl:otherwise><span class="separator"> | </span></xsl:otherwise></xsl:choose>
468             </xsl:for-each>
469
470             <xsl:for-each select="marc:datafield[@tag=830]">
471                 <xsl:choose>
472                     <xsl:when test="$UseControlNumber = '1' and marc:subfield[@code='w']">
473                         <a href="/cgi-bin/koha/catalogue/search.pl?q=rcn:{marc:subfield[@code='w']}">
474                             <xsl:call-template name="chopPunctuation">
475                                 <xsl:with-param name="chopString">
476                                     <xsl:call-template name="subfieldSelect">
477                                         <xsl:with-param name="codes">a_t</xsl:with-param>
478                                     </xsl:call-template>
479                                 </xsl:with-param>
480                             </xsl:call-template>
481                         </a>
482                     </xsl:when>
483                     <xsl:when test="marc:subfield[@code=9] and $UseAuthoritiesForTracings='1'">
484                         <a><xsl:attribute name="href"><xsl:value-of select="$searchurl"/>?q=an:<xsl:value-of select="str:encode-uri(marc:subfield[@code=9], true())"/></xsl:attribute>
485                             <xsl:call-template name="chopPunctuation">
486                                 <xsl:with-param name="chopString">
487                                     <xsl:call-template name="subfieldSelect">
488                                         <xsl:with-param name="codes">a_t</xsl:with-param>
489                                     </xsl:call-template>
490                                 </xsl:with-param>
491                             </xsl:call-template>
492                         </a>
493                     </xsl:when>
494                     <xsl:otherwise>
495                         <a><xsl:attribute name="href"><xsl:value-of select="$searchurl"/>?q=se,phr:"<xsl:value-of select="str:encode-uri(marc:subfield[@code='a'], true())"/>"</xsl:attribute>
496                             <xsl:call-template name="chopPunctuation">
497                                 <xsl:with-param name="chopString">
498                                     <xsl:call-template name="subfieldSelect">
499                                         <xsl:with-param name="codes">a_t</xsl:with-param>
500                                     </xsl:call-template>
501                                 </xsl:with-param>
502                             </xsl:call-template>
503                         </a>
504                     </xsl:otherwise>
505                 </xsl:choose>
506                 <xsl:call-template name="part"/>
507                 <xsl:if test="marc:subfield[@code='v']">
508                     <xsl:text> ; </xsl:text><xsl:value-of select="marc:subfield[@code='v']" />
509                 </xsl:if>
510             <xsl:choose><xsl:when test="position()=last()"><xsl:text></xsl:text></xsl:when><xsl:otherwise><span class="separator"> | </span></xsl:otherwise></xsl:choose>
511             </xsl:for-each>
512         </xsl:if>
513
514         </span>
515         </xsl:if>
516     </xsl:template>
517
518     <xsl:template name="part">
519         <xsl:variable name="partNumber">
520             <xsl:call-template name="specialSubfieldSelect">
521                 <xsl:with-param name="axis">n</xsl:with-param>
522                 <xsl:with-param name="anyCodes">n</xsl:with-param>
523                 <xsl:with-param name="afterCodes">fghkdlmor</xsl:with-param>
524             </xsl:call-template>
525         </xsl:variable>
526         <xsl:variable name="partName">
527             <xsl:call-template name="specialSubfieldSelect">
528                 <xsl:with-param name="axis">p</xsl:with-param>
529                 <xsl:with-param name="anyCodes">p</xsl:with-param>
530                 <xsl:with-param name="afterCodes">fghkdlmor</xsl:with-param>
531             </xsl:call-template>
532         </xsl:variable>
533         <xsl:if test="string-length(normalize-space($partNumber)) or string-length(normalize-space($partName))" >
534             <xsl:text>. </xsl:text>
535         </xsl:if>
536         <xsl:if test="string-length(normalize-space($partNumber))">
537             <xsl:value-of select="$partNumber" />
538         </xsl:if>
539         <xsl:if test="string-length(normalize-space($partNumber))"><xsl:text> </xsl:text></xsl:if>
540         <xsl:if test="string-length(normalize-space($partName))">
541             <xsl:value-of select="$partName" />
542         </xsl:if>
543     </xsl:template>
544
545     <xsl:template name="quote_search_term">
546         <xsl:param name="term" />
547         <xsl:text>"</xsl:text>
548         <xsl:call-template name="escape_quotes">
549             <xsl:with-param name="text">
550                 <xsl:value-of select="$term"/>
551             </xsl:with-param>
552         </xsl:call-template>
553         <xsl:text>"</xsl:text>
554     </xsl:template>
555
556     <xsl:template name="escape_quotes">
557         <xsl:param name="text"/>
558         <xsl:choose>
559             <xsl:when test="contains($text, '&quot;')">
560                 <xsl:variable name="before" select="substring-before($text,'&quot;')"/>
561                 <xsl:variable name="next" select="substring-after($text,'&quot;')"/>
562                 <xsl:value-of select="$before"/>
563                 <xsl:text>\&quot;</xsl:text>
564                 <xsl:call-template name="escape_quotes">
565                     <xsl:with-param name="text" select="$next"/>
566                 </xsl:call-template>
567             </xsl:when>
568             <xsl:otherwise>
569                 <xsl:value-of select="$text"/>
570             </xsl:otherwise>
571         </xsl:choose>
572     </xsl:template>
573
574 </xsl:stylesheet>
575
576 <!-- Stylus Studio meta-information - (c)1998-2002 eXcelon Corp.
577 <metaInformation>
578 <scenarios/><MapperInfo srcSchemaPath="" srcSchemaRoot="" srcSchemaPathIsRelative="yes" srcSchemaInterpretAsXML="no" destSchemaPath="" destSchemaRoot="" destSchemaPathIsRelative="yes" destSchemaInterpretAsXML="no"/>
579 </metaInformation>
580 -->