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="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="buildSpaces">
56 <xsl:param name="spaces"/>
57 <xsl:param name="char"><xsl:text> </xsl:text></xsl:param>
58 <xsl:if test="$spaces>0">
59 <xsl:value-of select="$char"/>
60 <xsl:call-template name="buildSpaces">
61 <xsl:with-param name="spaces" select="$spaces - 1"/>
62 <xsl:with-param name="char" select="$char"/>
67 <xsl:template name="buildBiblioDefaultViewURL">
68 <xsl:param name="BiblioDefaultView"/>
70 <xsl:when test="$BiblioDefaultView='normal'">
71 <xsl:text>/cgi-bin/koha/opac-detail.pl?biblionumber=</xsl:text>
73 <xsl:when test="$BiblioDefaultView='isbd'">
74 <xsl:text>/cgi-bin/koha/opac-ISBDdetail.pl?biblionumber=</xsl:text>
76 <xsl:when test="$BiblioDefaultView='marc'">
77 <xsl:text>/cgi-bin/koha/opac-MARCdetail.pl?biblionumber=</xsl:text>
80 <xsl:text>/cgi-bin/koha/opac-detail.pl?biblionumber=</xsl:text>
85 <xsl:template name="chopPunctuation">
86 <xsl:param name="chopString"/>
87 <xsl:variable name="length" select="string-length($chopString)"/>
89 <xsl:when test="$length=0"/>
90 <xsl:when test="contains('.:,;/ ', substring($chopString,$length,1))">
91 <xsl:call-template name="chopPunctuation">
92 <xsl:with-param name="chopString" select="substring($chopString,1,$length - 1)"/>
95 <xsl:when test="not($chopString)"/>
96 <xsl:otherwise><xsl:value-of select="$chopString"/></xsl:otherwise>
98 <xsl:text> </xsl:text>
101 <!-- Function extractControlNumber is used to extract the control number (record number) from MARC tags 773/80/85 [etc.] subfield $w.
102 Parameter: control number string.
103 Assumes LOC convention: (OrgCode)recordNumber.
104 If OrgCode is not present, return full string.
105 Additionally, handle various brackets/parentheses. Chop leading and trailing spaces.
106 Returns the value URI-encoded.
108 <xsl:template name="extractControlNumber">
109 <xsl:param name="subfieldW"/>
110 <xsl:variable name="tranW" select="translate($subfieldW,']})>','))))')"/>
112 <xsl:when test="contains($tranW,')')">
113 <xsl:value-of select="str:encode-uri(normalize-space(translate(substring-after($tranW,')'),'[]{}()<>','')), true())"/>
116 <xsl:value-of select="str:encode-uri(normalize-space($subfieldW), true())"/>
121 <xsl:template name="nameABCDQ">
122 <xsl:call-template name="chopPunctuation">
123 <xsl:with-param name="chopString">
124 <xsl:call-template name="subfieldSelect">
125 <xsl:with-param name="codes">aq</xsl:with-param>
128 <xsl:with-param name="punctuation">
129 <xsl:text>:,;/ </xsl:text>
132 <xsl:call-template name="termsOfAddress"/>
135 <xsl:template name="nameABCDN">
136 <xsl:for-each select="marc:subfield[@code='a']">
137 <xsl:call-template name="chopPunctuation">
138 <xsl:with-param name="chopString" select="."/>
141 <xsl:for-each select="marc:subfield[@code='b']">
142 <xsl:value-of select="."/>
144 <xsl:if test="marc:subfield[@code='c'] or marc:subfield[@code='d'] or marc:subfield[@code='n']">
145 <xsl:call-template name="subfieldSelect">
146 <xsl:with-param name="codes">cdn</xsl:with-param>
151 <xsl:template name="nameACDEQ">
152 <xsl:call-template name="subfieldSelect">
153 <xsl:with-param name="codes">acdeq</xsl:with-param>
157 <xsl:template name="termsOfAddress">
158 <xsl:if test="marc:subfield[@code='b' or @code='c']">
159 <xsl:call-template name="chopPunctuation">
160 <xsl:with-param name="chopString">
161 <xsl:call-template name="subfieldSelect">
162 <xsl:with-param name="codes">bc</xsl:with-param>
169 <!-- Function m880Select: Display Alternate Graphic Representation (MARC 880) for selected latin "base"tags
170 - should be called immediately before the corresonding latin tags are processed
171 - tags in right-to-left languages are displayed floating right
173 + basetags: display these tags if found in linkage section ( subfield 6) of tag 880
174 + codes: display these subfields codes
176 - class: wrap output in <span class="$class">...</span>
177 - label: prefix each(!) tag with label $label
178 - bibno: link to biblionumber $bibno
179 - 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.
181 - displays every field on a separate line (to switch between rtl and ltr)
183 (!) output might be empty
185 <xsl:template name="m880Select">
186 <xsl:param name="basetags"/> <!-- e.g. 100,700,110,710 -->
187 <xsl:param name="codes"/> <!-- e.g. abc -->
188 <xsl:param name="class"/> <!-- e.g. results_summary -->
189 <xsl:param name="label"/> <!-- e.g. Edition -->
190 <xsl:param name="bibno"/>
191 <xsl:param name="index"/> <!-- e.g. au -->
193 <xsl:for-each select="marc:datafield[@tag=880]">
194 <xsl:variable name="code6" select="marc:subfield[@code=6]"/>
195 <xsl:if test="contains(string($basetags), substring($code6,1,3))">
197 <xsl:if test="boolean($class)">
198 <xsl:attribute name="class"><xsl:value-of select="$class"/></xsl:attribute>
201 <!-- display right-to-left tags floating right of their left-to-right counterparts -->
202 <xsl:when test="substring($code6,10,2) ='/r'">
203 <xsl:attribute name="style">display:block; text-align:right; float:right; width:50%; padding-left:20px</xsl:attribute>
204 <xsl:attribute name="dir">rtl</xsl:attribute>
207 <xsl:attribute name="style">display:block; </xsl:attribute>
210 <xsl:if test="boolean($label)">
212 <xsl:value-of select="$label"/>
215 <xsl:variable name="str">
216 <xsl:for-each select="marc:subfield">
217 <xsl:if test="contains($codes, @code)">
218 <xsl:value-of select="text()"/>
219 <xsl:text> </xsl:text>
223 <xsl:if test="string-length($str) > 0">
225 <xsl:when test="boolean($bibno)">
227 <xsl:attribute name="href">/cgi-bin/koha/opac-detail.pl?biblionumber=<xsl:value-of select="str:encode-uri($bibno, true())"/></xsl:attribute>
228 <xsl:value-of select="$str"/>
231 <xsl:when test="boolean($index) and boolean(marc:subfield[@code=9])">
233 <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>
234 <xsl:value-of select="$str"/>
237 <xsl:when test="boolean($index)">
239 <xsl:attribute name="href">/cgi-bin/koha/opac-search.pl?q=<xsl:value-of select="$index"/>:<xsl:value-of select="str:encode-uri(marc:subfield[@code='a'], true())"/></xsl:attribute>
240 <xsl:value-of select="$str"/>
244 <xsl:value-of select="$str"/>
256 <!-- Stylus Studio meta-information - (c)1998-2002 eXcelon Corp.
258 <scenarios/><MapperInfo srcSchemaPath="" srcSchemaRoot="" srcSchemaPathIsRelative="yes" srcSchemaInterpretAsXML="no" destSchemaPath="" destSchemaRoot="" destSchemaPathIsRelative="yes" destSchemaInterpretAsXML="no"/>