2 <!DOCTYPE stylesheet [<!ENTITY nbsp " " >]>
3 <xsl:stylesheet version="1.0" xmlns:marc="http://www.loc.gov/MARC21/slim" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
4 <xsl:template name="datafield">
5 <xsl:param name="tag"/>
6 <xsl:param name="ind1"><xsl:text> </xsl:text></xsl:param>
7 <xsl:param name="ind2"><xsl:text> </xsl:text></xsl:param>
8 <xsl:param name="subfields"/>
9 <xsl:element name="datafield">
10 <xsl:attribute name="tag">
11 <xsl:value-of select="$tag"/>
13 <xsl:attribute name="ind1">
14 <xsl:value-of select="$ind1"/>
16 <xsl:attribute name="ind2">
17 <xsl:value-of select="$ind2"/>
19 <xsl:copy-of select="$subfields"/>
23 <xsl:template name="subfieldSelect">
24 <xsl:param name="codes"/>
25 <xsl:param name="delimeter"><xsl:text> </xsl:text></xsl:param>
26 <xsl:param name="subdivCodes"/>
27 <xsl:param name="subdivDelimiter"/>
28 <xsl:param name="prefix"/>
29 <xsl:param name="suffix"/>
30 <xsl:variable name="str">
31 <xsl:for-each select="marc:subfield">
32 <xsl:if test="contains($codes, @code)">
33 <xsl:if test="contains($subdivCodes, @code)">
34 <xsl:value-of select="$subdivDelimiter"/>
36 <xsl:value-of select="$prefix"/><xsl:value-of select="text()"/><xsl:value-of select="$suffix"/><xsl:value-of select="$delimeter"/>
40 <xsl:value-of select="substring($str,1,string-length($str)-string-length($delimeter))"/>
43 <xsl:template name="buildSpaces">
44 <xsl:param name="spaces"/>
45 <xsl:param name="char"><xsl:text> </xsl:text></xsl:param>
46 <xsl:if test="$spaces>0">
47 <xsl:value-of select="$char"/>
48 <xsl:call-template name="buildSpaces">
49 <xsl:with-param name="spaces" select="$spaces - 1"/>
50 <xsl:with-param name="char" select="$char"/>
55 <xsl:template name="buildBiblioDefaultViewURL">
56 <xsl:param name="BiblioDefaultView"/>
58 <xsl:when test="$BiblioDefaultView='normal'">
59 <xsl:text>/cgi-bin/koha/opac-detail.pl?biblionumber=</xsl:text>
61 <xsl:when test="$BiblioDefaultView='isbd'">
62 <xsl:text>/cgi-bin/koha/opac-ISBDdetail.pl?biblionumber=</xsl:text>
64 <xsl:when test="$BiblioDefaultView='marc'">
65 <xsl:text>/cgi-bin/koha/opac-MARCdetail.pl?biblionumber=</xsl:text>
68 <xsl:text>/cgi-bin/koha/opac-detail.pl?biblionumber=</xsl:text>
73 <xsl:template name="chopPunctuation">
74 <xsl:param name="chopString"/>
75 <xsl:variable name="length" select="string-length($chopString)"/>
77 <xsl:when test="$length=0"/>
78 <xsl:when test="contains('.:,;/ ', substring($chopString,$length,1))">
79 <xsl:call-template name="chopPunctuation">
80 <xsl:with-param name="chopString" select="substring($chopString,1,$length - 1)"/>
83 <xsl:when test="not($chopString)"/>
84 <xsl:otherwise><xsl:value-of select="$chopString"/></xsl:otherwise>
86 <xsl:text> </xsl:text>
89 <!-- Function extractControlNumber is used to extract the control number (record number) from MARC tags 773/80/85 [etc.] subfield $w.
90 Parameter: control number string.
91 Assumes LOC convention: (OrgCode)recordNumber.
92 If OrgCode is not present, return full string.
93 Additionally, handle various brackets/parentheses. Chop leading and trailing spaces.
95 <xsl:template name="extractControlNumber">
96 <xsl:param name="subfieldW"/>
97 <xsl:variable name="tranW" select="translate($subfieldW,']})>','))))')"/>
99 <xsl:when test="contains($tranW,')')">
100 <xsl:value-of select="normalize-space(translate(substring-after($tranW,')'),'[]{}()<>',''))"/>
103 <xsl:value-of select="normalize-space($subfieldW)"/>
108 <xsl:template name="nameABCDQ">
109 <xsl:call-template name="chopPunctuation">
110 <xsl:with-param name="chopString">
111 <xsl:call-template name="subfieldSelect">
112 <xsl:with-param name="codes">aq</xsl:with-param>
115 <xsl:with-param name="punctuation">
116 <xsl:text>:,;/ </xsl:text>
119 <xsl:call-template name="termsOfAddress"/>
122 <xsl:template name="nameABCDN">
123 <xsl:for-each select="marc:subfield[@code='a']">
124 <xsl:call-template name="chopPunctuation">
125 <xsl:with-param name="chopString" select="."/>
128 <xsl:for-each select="marc:subfield[@code='b']">
129 <xsl:value-of select="."/>
131 <xsl:if test="marc:subfield[@code='c'] or marc:subfield[@code='d'] or marc:subfield[@code='n']">
132 <xsl:call-template name="subfieldSelect">
133 <xsl:with-param name="codes">cdn</xsl:with-param>
138 <xsl:template name="nameACDEQ">
139 <xsl:call-template name="subfieldSelect">
140 <xsl:with-param name="codes">acdeq</xsl:with-param>
144 <xsl:template name="termsOfAddress">
145 <xsl:if test="marc:subfield[@code='b' or @code='c']">
146 <xsl:call-template name="chopPunctuation">
147 <xsl:with-param name="chopString">
148 <xsl:call-template name="subfieldSelect">
149 <xsl:with-param name="codes">bc</xsl:with-param>
156 <!-- Function m880Select: Display Alternate Graphic Representation (MARC 880) for selected latin "base"tags
157 - should be called immediately before the corresonding latin tags are processed
158 - tags in right-to-left languages are displayed floating right
160 + basetags: display these tags if found in linkage section ( subfield 6) of tag 880
161 + codes: display these subfields codes
163 - class: wrap output in <span class="$class">...</span>
164 - label: prefix each(!) tag with label $label
165 - bibno: link to biblionumber $bibno
166 - 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.
168 - displays every field on a separate line (to switch between rtl and ltr)
170 (!) output might be empty
172 <xsl:template name="m880Select">
173 <xsl:param name="basetags"/> <!-- e.g. 100,700,110,710 -->
174 <xsl:param name="codes"/> <!-- e.g. abc -->
175 <xsl:param name="class"/> <!-- e.g. results_summary -->
176 <xsl:param name="label"/> <!-- e.g. Edition -->
177 <xsl:param name="bibno"/>
178 <xsl:param name="index"/> <!-- e.g. au -->
180 <xsl:for-each select="marc:datafield[@tag=880]">
181 <xsl:variable name="code6" select="marc:subfield[@code=6]"/>
182 <xsl:if test="contains(string($basetags), substring($code6,1,3))">
184 <xsl:if test="boolean($class)">
185 <xsl:attribute name="class"><xsl:value-of select="$class"/></xsl:attribute>
188 <!-- display right-to-left tags floating right of their left-to-right counterparts -->
189 <xsl:when test="substring($code6,10,2) ='/r'">
190 <xsl:attribute name="style">display:block; text-align:right; float:right; width:50%; padding-left:20px</xsl:attribute>
191 <xsl:attribute name="dir">rtl</xsl:attribute>
194 <xsl:attribute name="style">display:block; </xsl:attribute>
197 <xsl:if test="boolean($label)">
199 <xsl:value-of select="$label"/>
202 <xsl:variable name="str">
203 <xsl:for-each select="marc:subfield">
204 <xsl:if test="contains($codes, @code)">
205 <xsl:value-of select="text()"/>
206 <xsl:text> </xsl:text>
210 <xsl:if test="string-length($str) > 0">
212 <xsl:when test="boolean($bibno)">
214 <xsl:attribute name="href">/cgi-bin/koha/opac-detail.pl?biblionumber=<xsl:value-of select="$bibno"/></xsl:attribute>
215 <xsl:value-of select="$str"/>
218 <xsl:when test="boolean($index) and boolean(marc:subfield[@code=9])">
220 <xsl:attribute name="href">/cgi-bin/koha/opac-search.pl?q=an:<xsl:value-of select="marc:subfield[@code=9]"/></xsl:attribute>
221 <xsl:value-of select="$str"/>
224 <xsl:when test="boolean($index)">
226 <xsl:attribute name="href">/cgi-bin/koha/opac-search.pl?q=<xsl:value-of select="$index"/>:<xsl:value-of select="marc:subfield[@code='a']"/></xsl:attribute>
227 <xsl:value-of select="$str"/>
231 <xsl:value-of select="$str"/>
243 <!-- Stylus Studio meta-information - (c)1998-2002 eXcelon Corp.
245 <scenarios/><MapperInfo srcSchemaPath="" srcSchemaRoot="" srcSchemaPathIsRelative="yes" srcSchemaInterpretAsXML="no" destSchemaPath="" destSchemaRoot="" destSchemaPathIsRelative="yes" destSchemaInterpretAsXML="no"/>