2 <!DOCTYPE stylesheet [<!ENTITY nbsp " " >]>
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:template name="datafield">
9 <xsl:param name="tag"/>
10 <xsl:param name="ind1"><xsl:text> </xsl:text></xsl:param>
11 <xsl:param name="ind2"><xsl:text> </xsl:text></xsl:param>
12 <xsl:param name="subfields"/>
13 <xsl:element name="datafield">
14 <xsl:attribute name="tag">
15 <xsl:value-of select="$tag"/>
17 <xsl:attribute name="ind1">
18 <xsl:value-of select="$ind1"/>
20 <xsl:attribute name="ind2">
21 <xsl:value-of select="$ind2"/>
23 <xsl:copy-of select="$subfields"/>
27 <xsl:template name="subfieldSelect">
28 <xsl:param name="codes"/>
29 <xsl:param name="delimeter"><xsl:text> </xsl:text></xsl:param>
30 <xsl:param name="subdivCodes"/>
31 <xsl:param name="subdivDelimiter"/>
32 <xsl:param name="prefix"/>
33 <xsl:param name="suffix"/>
34 <xsl:param name="urlencode"/>
35 <xsl:variable name="str">
36 <xsl:for-each select="marc:subfield">
37 <xsl:if test="contains($codes, @code)">
38 <xsl:if test="contains($subdivCodes, @code)">
39 <xsl:value-of select="$subdivDelimiter"/>
41 <xsl:value-of select="$prefix"/><xsl:value-of select="text()"/><xsl:value-of select="$suffix"/><xsl:value-of select="$delimeter"/>
46 <xsl:when test="$urlencode=1">
47 <xsl:value-of select="str:encode-uri(substring($str,1,string-length($str)-string-length($delimeter)), true())"/>
50 <xsl:value-of select="substring($str,1,string-length($str)-string-length($delimeter))"/>
55 <xsl:template name="subfieldSelectSpan">
56 <xsl:param name="codes"/>
57 <xsl:param name="delimeter"><xsl:text> </xsl:text></xsl:param>
58 <xsl:param name="subdivCodes"/>
59 <xsl:param name="subdivDelimiter"/>
60 <xsl:param name="prefix"/>
61 <xsl:param name="suffix"/>
62 <xsl:for-each select="marc:subfield">
63 <xsl:if test="contains($codes, @code)">
65 <xsl:attribute name="class"><xsl:value-of select="@code"/></xsl:attribute>
66 <xsl:if test="contains($subdivCodes, @code)">
67 <xsl:value-of select="$subdivDelimiter"/>
69 <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>
75 <xsl:template name="buildSpaces">
76 <xsl:param name="spaces"/>
77 <xsl:param name="char"><xsl:text> </xsl:text></xsl:param>
78 <xsl:if test="$spaces>0">
79 <xsl:value-of select="$char"/>
80 <xsl:call-template name="buildSpaces">
81 <xsl:with-param name="spaces" select="$spaces - 1"/>
82 <xsl:with-param name="char" select="$char"/>
87 <xsl:template name="buildBiblioDefaultViewURL">
88 <xsl:param name="BiblioDefaultView"/>
90 <xsl:when test="$BiblioDefaultView='normal'">
91 <xsl:text>/cgi-bin/koha/opac-detail.pl?biblionumber=</xsl:text>
93 <xsl:when test="$BiblioDefaultView='isbd'">
94 <xsl:text>/cgi-bin/koha/opac-ISBDdetail.pl?biblionumber=</xsl:text>
96 <xsl:when test="$BiblioDefaultView='marc'">
97 <xsl:text>/cgi-bin/koha/opac-MARCdetail.pl?biblionumber=</xsl:text>
100 <xsl:text>/cgi-bin/koha/opac-detail.pl?biblionumber=</xsl:text>
105 <xsl:template name="chopPunctuation">
106 <xsl:param name="chopString"/>
107 <xsl:variable name="length" select="string-length($chopString)"/>
109 <xsl:when test="$length=0"/>
110 <xsl:when test="contains('.:,;/ ', substring($chopString,$length,1))">
111 <xsl:call-template name="chopPunctuation">
112 <xsl:with-param name="chopString" select="substring($chopString,1,$length - 1)"/>
115 <xsl:when test="not($chopString)"/>
116 <xsl:otherwise><xsl:value-of select="$chopString"/></xsl:otherwise>
120 <!-- Function extractControlNumber is used to extract the control number (record number) from MARC tags 773/80/85 [etc.] subfield $w.
121 Parameter: control number string.
122 Assumes LOC convention: (OrgCode)recordNumber.
123 If OrgCode is not present, return full string.
124 Additionally, handle various brackets/parentheses. Chop leading and trailing spaces.
125 Returns the value URI-encoded.
127 <xsl:template name="extractControlNumber">
128 <xsl:param name="subfieldW"/>
129 <xsl:variable name="tranW" select="translate($subfieldW,']})>','))))')"/>
131 <xsl:when test="contains($tranW,')')">
132 <xsl:value-of select="str:encode-uri(normalize-space(translate(substring-after($tranW,')'),'[]{}()<>','')), true())"/>
135 <xsl:value-of select="str:encode-uri(normalize-space($subfieldW), true())"/>
140 <!-- Function m880Select: Display Alternate Graphic Representation (MARC 880) for selected latin "base"tags
141 - should be called immediately before the corresonding latin tags are processed
142 - tags in right-to-left languages are displayed floating right
144 + basetags: display these tags if found in linkage section ( subfield 6) of tag 880
145 + codes: display these subfields codes
147 - class: wrap output in <span class="$class">...</span>
148 - label: prefix each(!) tag with label $label
149 - bibno: link to biblionumber $bibno
150 - 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.
152 - displays every field on a separate line (to switch between rtl and ltr)
154 (!) output might be empty
156 <xsl:template name="m880Select">
157 <xsl:param name="basetags"/> <!-- e.g. 100,700,110,710 -->
158 <xsl:param name="codes"/> <!-- e.g. abc -->
159 <xsl:param name="class"/> <!-- e.g. results_summary -->
160 <xsl:param name="label"/> <!-- e.g. Edition -->
161 <xsl:param name="bibno"/>
162 <xsl:param name="index"/> <!-- e.g. au -->
164 <xsl:for-each select="marc:datafield[@tag=880]">
165 <xsl:variable name="code6" select="marc:subfield[@code=6]"/>
166 <xsl:if test="contains(string($basetags), substring($code6,1,3))">
169 <xsl:when test="boolean($class) and substring($code6,string-length($code6)-1,2) ='/r'">
170 <xsl:attribute name="class"><xsl:value-of select="$class"/> m880</xsl:attribute>
171 <xsl:attribute name="dir">rtl</xsl:attribute>
173 <xsl:when test="boolean($class)">
174 <xsl:attribute name="class"><xsl:value-of select="$class"/></xsl:attribute>
175 <xsl:attribute name="style">display:block; </xsl:attribute>
177 <xsl:when test="substring($code6,string-length($code6)-1,2) ='/r'">
178 <xsl:attribute name="class"><xsl:value-of select="$class"/> m880</xsl:attribute>
181 <xsl:if test="boolean($label)">
183 <xsl:value-of select="$label"/>
186 <xsl:variable name="str">
187 <xsl:for-each select="marc:subfield">
188 <xsl:if test="contains($codes, @code)">
189 <xsl:value-of select="text()"/>
190 <xsl:text> </xsl:text>
194 <xsl:if test="string-length($str) > 0">
196 <xsl:when test="boolean($bibno)">
198 <xsl:attribute name="href">/cgi-bin/koha/opac-detail.pl?biblionumber=<xsl:value-of select="str:encode-uri($bibno, true())"/></xsl:attribute>
199 <xsl:value-of select="$str"/>
202 <xsl:when test="boolean($index) and boolean(marc:subfield[@code=9])">
204 <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>
205 <xsl:value-of select="$str"/>
208 <xsl:when test="boolean($index)">
210 <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>
211 <xsl:value-of select="$str"/>
215 <xsl:value-of select="$str"/>
224 <xsl:template name="showRDAtag264">
225 <!-- Function showRDAtag264 shows selected information from tag 264
226 on the Publisher line (used by OPAC Detail and Results)
227 Depending on how many tags you have, we will pick by preference
228 Publisher-latest or Publisher or 'Other'-latest or 'Other'
229 The preferred tag is saved in the fav variable and passed to a
230 helper named-template -->
231 <!-- Amended to show all 264 fields (filtered by ind1=3 if ind1=3 is present in the record) -->
232 <xsl:param name="show_url"/>
234 <xsl:when test="marc:datafield[@tag=264 and @ind1=3]">
235 <xsl:for-each select="marc:datafield[@tag=264 and @ind1=3]">
236 <xsl:call-template name="showRDAtag264helper">
237 <xsl:with-param name="field" select="."/>
238 <xsl:with-param name="url" select="$show_url"/>
243 <xsl:for-each select="marc:datafield[@tag=264]">
244 <xsl:call-template name="showRDAtag264helper">
245 <xsl:with-param name="field" select="."/>
246 <xsl:with-param name="url" select="$show_url"/>
252 <xsl:template name="showRDAtag264helper">
253 <xsl:param name="field"/>
254 <xsl:param name="url"/>
255 <xsl:variable name="ind2" select="$field/@ind2"/>
256 <span class="results_summary">
258 <xsl:when test="$ind2='0'">
259 <span class="label">Producer: </span>
261 <xsl:when test="$ind2='1'">
262 <span class="label">Publisher: </span>
264 <xsl:when test="$ind2='2'">
265 <span class="label">Distributor: </span>
267 <xsl:when test="$ind2='3'">
268 <span class="label">Manufacturer: </span>
270 <xsl:when test="$ind2='4'">
271 <span class="label">Copyright date: </span>
275 <xsl:if test="$field/marc:subfield[@code='a']">
276 <xsl:call-template name="subfieldSelect">
277 <xsl:with-param name="codes">a</xsl:with-param>
280 <xsl:text> </xsl:text>
283 <xsl:when test="$url='1'">
284 <xsl:if test="$field/marc:subfield[@code='b']">
286 <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>
287 <xsl:call-template name="subfieldSelect">
288 <xsl:with-param name="codes">b</xsl:with-param>
294 <xsl:if test="$field/marc:subfield[@code='b']">
295 <xsl:call-template name="subfieldSelect">
296 <xsl:with-param name="codes">b</xsl:with-param>
301 <xsl:text> </xsl:text>
302 <xsl:call-template name="chopPunctuation">
303 <xsl:with-param name="chopString">
304 <xsl:call-template name="subfieldSelect">
305 <xsl:with-param name="codes">c</xsl:with-param>
314 <!-- Stylus Studio meta-information - (c)1998-2002 eXcelon Corp.
316 <scenarios/><MapperInfo srcSchemaPath="" srcSchemaRoot="" srcSchemaPathIsRelative="yes" srcSchemaInterpretAsXML="no" destSchemaPath="" destSchemaRoot="" destSchemaPathIsRelative="yes" destSchemaInterpretAsXML="no"/>