3 <!DOCTYPE stylesheet [<!ENTITY nbsp " " >]>
5 <xsl:stylesheet version="1.0"
6 xmlns:marc="http://www.loc.gov/MARC21/slim"
7 xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
8 xmlns:str="http://exslt.org/strings">
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"/>
18 <xsl:attribute name="ind1">
19 <xsl:value-of select="$ind1"/>
21 <xsl:attribute name="ind2">
22 <xsl:value-of select="$ind2"/>
24 <xsl:copy-of select="$subfields"/>
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"/>
42 <xsl:value-of select="$prefix"/><xsl:value-of select="text()"/><xsl:value-of select="$suffix"/><xsl:value-of select="$delimeter"/>
47 <xsl:when test="$urlencode=1">
48 <xsl:value-of select="str:encode-uri(substring($str,1,string-length($str)-string-length($delimeter)), true())"/>
51 <xsl:value-of select="substring($str,1,string-length($str)-string-length($delimeter))"/>
56 <xsl:template name="buildSpaces">
57 <xsl:param name="spaces"/>
58 <xsl:param name="char"><xsl:text> </xsl:text></xsl:param>
59 <xsl:if test="$spaces>0">
60 <xsl:value-of select="$char"/>
61 <xsl:call-template name="buildSpaces">
62 <xsl:with-param name="spaces" select="$spaces - 1"/>
63 <xsl:with-param name="char" select="$char"/>
68 <xsl:template name="buildBiblioDefaultViewURL">
69 <xsl:param name="IntranetBiblioDefaultView"/>
71 <xsl:when test="$IntranetBiblioDefaultView='normal'">
72 <xsl:text>/cgi-bin/koha/catalogue/detail.pl?biblionumber=</xsl:text>
74 <xsl:when test="$IntranetBiblioDefaultView='isbd'">
75 <xsl:text>/cgi-bin/koha/catalogue/ISBDdetail.pl?biblionumber=</xsl:text>
77 <xsl:when test="$IntranetBiblioDefaultView='labeled_marc'">
78 <xsl:text>/cgi-bin/koha/catalogue/labeledMARCdetail.pl?biblionumber=</xsl:text>
80 <xsl:when test="$IntranetBiblioDefaultView='marc'">
81 <xsl:text>/cgi-bin/koha/catalogue/MARCdetail.pl?biblionumber=</xsl:text>
84 <xsl:text>/cgi-bin/koha/catalogue/detail.pl?biblionumber=</xsl:text>
89 <xsl:template name="chopPunctuation">
90 <xsl:param name="chopString"/>
91 <xsl:variable name="length" select="string-length($chopString)"/>
93 <xsl:when test="$length=0"/>
94 <xsl:when test="contains('.:,;/ ', substring($chopString,$length,1))">
95 <xsl:call-template name="chopPunctuation">
96 <xsl:with-param name="chopString" select="substring($chopString,1,$length - 1)"/>
99 <xsl:when test="not($chopString)"/>
100 <xsl:otherwise><xsl:value-of select="$chopString"/></xsl:otherwise>
102 <xsl:text> </xsl:text>
105 <!-- Function extractControlNumber is used to extract the control number (record number) from MARC tags 773/80/85 [etc.] subfield $w.
106 Parameter: control number string.
107 Assumes LOC convention: (OrgCode)recordNumber.
108 If OrgCode is not present, return full string.
109 Additionally, handle various brackets/parentheses. Chop leading and trailing spaces.
110 Returns the value URI-encoded.
112 <xsl:template name="extractControlNumber">
113 <xsl:param name="subfieldW"/>
114 <xsl:variable name="tranW" select="translate($subfieldW,']})>','))))')"/>
116 <xsl:when test="contains($tranW,')')">
117 <xsl:value-of select="str:encode-uri(normalize-space(translate(substring-after($tranW,')'),'[]{}()<>','')), true())"/>
120 <xsl:value-of select="str:encode-uri(normalize-space($subfieldW), true())"/>
125 <xsl:template name="nameABCDQ">
126 <xsl:call-template name="chopPunctuation">
127 <xsl:with-param name="chopString">
128 <xsl:call-template name="subfieldSelect">
129 <xsl:with-param name="codes">aq</xsl:with-param>
132 <xsl:with-param name="punctuation">
133 <xsl:text>:,;/ </xsl:text>
136 <xsl:call-template name="termsOfAddress"/>
139 <xsl:template name="nameABCDN">
140 <xsl:for-each select="marc:subfield[@code='a']">
141 <xsl:call-template name="chopPunctuation">
142 <xsl:with-param name="chopString" select="."/>
145 <xsl:for-each select="marc:subfield[@code='b']">
146 <xsl:value-of select="."/>
148 <xsl:if test="marc:subfield[@code='c'] or marc:subfield[@code='d'] or marc:subfield[@code='n']">
149 <xsl:call-template name="subfieldSelect">
150 <xsl:with-param name="codes">cdn</xsl:with-param>
155 <xsl:template name="nameACDEQ">
156 <xsl:call-template name="subfieldSelect">
157 <xsl:with-param name="codes">acdeq</xsl:with-param>
161 <xsl:template name="termsOfAddress">
162 <xsl:if test="marc:subfield[@code='b' or @code='c']">
163 <xsl:call-template name="chopPunctuation">
164 <xsl:with-param name="chopString">
165 <xsl:call-template name="subfieldSelect">
166 <xsl:with-param name="codes">bc</xsl:with-param>
173 <!-- Function m880Select: Display Alternate Graphic Representation (MARC 880) for selected latin "base"tags
174 - should be called immediately before the corresonding latin tags are processed
175 - tags in right-to-left languages are displayed floating right
177 + basetags: display these tags if found in linkage section ( subfield 6) of tag 880
178 + codes: display these subfields codes
180 - class: wrap output in <span class="$class">...</span>
181 - label: prefix each(!) tag with label $label
182 - bibno: link to biblionumber $bibno
183 - 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.
185 - displays every field on a separate line (to switch between rtl and ltr)
187 (!) output might be empty
189 <xsl:template name="m880Select">
190 <xsl:param name="basetags"/> <!-- e.g. 100,700,110,710 -->
191 <xsl:param name="codes"/> <!-- e.g. abc -->
192 <xsl:param name="class"/> <!-- e.g. results_summary -->
193 <xsl:param name="label"/> <!-- e.g. Edition -->
194 <xsl:param name="bibno"/>
195 <xsl:param name="index"/> <!-- e.g. au -->
197 <xsl:for-each select="marc:datafield[@tag=880]">
198 <xsl:variable name="code6" select="marc:subfield[@code=6]"/>
199 <xsl:if test="contains(string($basetags), substring($code6,1,3))">
201 <xsl:if test="boolean($class)">
202 <xsl:attribute name="class"><xsl:value-of select="$class"/></xsl:attribute>
205 <!-- display right-to-left tags floating right of their left-to-right counterparts -->
206 <xsl:when test="substring($code6,10,2) ='/r'">
207 <xsl:attribute name="style">display:block; text-align:right; float:right; width:50%; padding-left:20px</xsl:attribute>
208 <xsl:attribute name="dir">rtl</xsl:attribute>
211 <xsl:attribute name="style">display:block; </xsl:attribute>
214 <xsl:if test="boolean($label)">
216 <xsl:value-of select="$label"/>
219 <xsl:variable name="str">
220 <xsl:for-each select="marc:subfield">
221 <xsl:if test="contains($codes, @code)">
222 <xsl:value-of select="text()"/>
223 <xsl:text> </xsl:text>
228 <xsl:when test="boolean($bibno)">
230 <xsl:attribute name="href">/cgi-bin/koha/opac-detail.pl?biblionumber=<xsl:value-of select="str:encode-uri($bibno, true())"/></xsl:attribute>
231 <xsl:value-of select="$str"/>
234 <xsl:when test="boolean($index) and boolean(marc:subfield[@code=9])">
236 <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>
237 <xsl:value-of select="$str"/>
240 <xsl:when test="boolean($index)">
242 <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>
243 <xsl:value-of select="$str"/>
247 <xsl:value-of select="$str"/>
258 <!-- Stylus Studio meta-information - (c)1998-2002 eXcelon Corp.
260 <scenarios/><MapperInfo srcSchemaPath="" srcSchemaRoot="" srcSchemaPathIsRelative="yes" srcSchemaInterpretAsXML="no" destSchemaPath="" destSchemaRoot="" destSchemaPathIsRelative="yes" destSchemaInterpretAsXML="no"/>