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: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"/>
45 <xsl:value-of select="substring($str,1,string-length($str)-string-length($delimeter))"/>
48 <xsl:template name="buildSpaces">
49 <xsl:param name="spaces"/>
50 <xsl:param name="char"><xsl:text> </xsl:text></xsl:param>
51 <xsl:if test="$spaces>0">
52 <xsl:value-of select="$char"/>
53 <xsl:call-template name="buildSpaces">
54 <xsl:with-param name="spaces" select="$spaces - 1"/>
55 <xsl:with-param name="char" select="$char"/>
60 <xsl:template name="buildBiblioDefaultViewURL">
61 <xsl:param name="IntranetBiblioDefaultView"/>
63 <xsl:when test="$IntranetBiblioDefaultView='normal'">
64 <xsl:text>/cgi-bin/koha/catalogue/detail.pl?biblionumber=</xsl:text>
66 <xsl:when test="$IntranetBiblioDefaultView='isbd'">
67 <xsl:text>/cgi-bin/koha/catalogue/ISBDdetail.pl?biblionumber=</xsl:text>
69 <xsl:when test="$IntranetBiblioDefaultView='labeled_marc'">
70 <xsl:text>/cgi-bin/koha/catalogue/labeledMARCdetail.pl?biblionumber=</xsl:text>
72 <xsl:when test="$IntranetBiblioDefaultView='marc'">
73 <xsl:text>/cgi-bin/koha/catalogue/MARCdetail.pl?biblionumber=</xsl:text>
76 <xsl:text>/cgi-bin/koha/catalogue/detail.pl?biblionumber=</xsl:text>
81 <xsl:template name="chopPunctuation">
82 <xsl:param name="chopString"/>
83 <xsl:variable name="length" select="string-length($chopString)"/>
85 <xsl:when test="$length=0"/>
86 <xsl:when test="contains('.:,;/ ', substring($chopString,$length,1))">
87 <xsl:call-template name="chopPunctuation">
88 <xsl:with-param name="chopString" select="substring($chopString,1,$length - 1)"/>
91 <xsl:when test="not($chopString)"/>
92 <xsl:otherwise><xsl:value-of select="$chopString"/></xsl:otherwise>
94 <xsl:text> </xsl:text>
97 <!-- Function extractControlNumber is used to extract the control number (record number) from MARC tags 773/80/85 [etc.] subfield $w.
98 Parameter: control number string.
99 Assumes LOC convention: (OrgCode)recordNumber.
100 If OrgCode is not present, return full string.
101 Additionally, handle various brackets/parentheses. Chop leading and trailing spaces.
103 <xsl:template name="extractControlNumber">
104 <xsl:param name="subfieldW"/>
105 <xsl:variable name="tranW" select="translate($subfieldW,']})>','))))')"/>
107 <xsl:when test="contains($tranW,')')">
108 <xsl:value-of select="normalize-space(translate(substring-after($tranW,')'),'[]{}()<>',''))"/>
111 <xsl:value-of select="normalize-space($subfieldW)"/>
116 <xsl:template name="nameABCDQ">
117 <xsl:call-template name="chopPunctuation">
118 <xsl:with-param name="chopString">
119 <xsl:call-template name="subfieldSelect">
120 <xsl:with-param name="codes">aq</xsl:with-param>
123 <xsl:with-param name="punctuation">
124 <xsl:text>:,;/ </xsl:text>
127 <xsl:call-template name="termsOfAddress"/>
130 <xsl:template name="nameABCDN">
131 <xsl:for-each select="marc:subfield[@code='a']">
132 <xsl:call-template name="chopPunctuation">
133 <xsl:with-param name="chopString" select="."/>
136 <xsl:for-each select="marc:subfield[@code='b']">
137 <xsl:value-of select="."/>
139 <xsl:if test="marc:subfield[@code='c'] or marc:subfield[@code='d'] or marc:subfield[@code='n']">
140 <xsl:call-template name="subfieldSelect">
141 <xsl:with-param name="codes">cdn</xsl:with-param>
146 <xsl:template name="nameACDEQ">
147 <xsl:call-template name="subfieldSelect">
148 <xsl:with-param name="codes">acdeq</xsl:with-param>
152 <xsl:template name="termsOfAddress">
153 <xsl:if test="marc:subfield[@code='b' or @code='c']">
154 <xsl:call-template name="chopPunctuation">
155 <xsl:with-param name="chopString">
156 <xsl:call-template name="subfieldSelect">
157 <xsl:with-param name="codes">bc</xsl:with-param>
164 <!-- Function m880Select: Display Alternate Graphic Representation (MARC 880) for selected latin "base"tags
165 - should be called immediately before the corresonding latin tags are processed
166 - tags in right-to-left languages are displayed floating right
168 + basetags: display these tags if found in linkage section ( subfield 6) of tag 880
169 + codes: display these subfields codes
171 - class: wrap output in <span class="$class">...</span>
172 - label: prefix each(!) tag with label $label
173 - bibno: link to biblionumber $bibno
174 - 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.
176 - displays every field on a separate line (to switch between rtl and ltr)
178 (!) output might be empty
180 <xsl:template name="m880Select">
181 <xsl:param name="basetags"/> <!-- e.g. 100,700,110,710 -->
182 <xsl:param name="codes"/> <!-- e.g. abc -->
183 <xsl:param name="class"/> <!-- e.g. results_summary -->
184 <xsl:param name="label"/> <!-- e.g. Edition -->
185 <xsl:param name="bibno"/>
186 <xsl:param name="index"/> <!-- e.g. au -->
188 <xsl:for-each select="marc:datafield[@tag=880]">
189 <xsl:variable name="code6" select="marc:subfield[@code=6]"/>
190 <xsl:if test="contains(string($basetags), substring($code6,1,3))">
192 <xsl:if test="boolean($class)">
193 <xsl:attribute name="class"><xsl:value-of select="$class"/></xsl:attribute>
196 <!-- display right-to-left tags floating right of their left-to-right counterparts -->
197 <xsl:when test="substring($code6,10,2) ='/r'">
198 <xsl:attribute name="style">display:block; text-align:right; float:right; width:50%; padding-left:20px</xsl:attribute>
199 <xsl:attribute name="dir">rtl</xsl:attribute>
202 <xsl:attribute name="style">display:block; </xsl:attribute>
205 <xsl:if test="boolean($label)">
207 <xsl:value-of select="$label"/>
210 <xsl:variable name="str">
211 <xsl:for-each select="marc:subfield">
212 <xsl:if test="contains($codes, @code)">
213 <xsl:value-of select="text()"/>
214 <xsl:text> </xsl:text>
219 <xsl:when test="boolean($bibno)">
221 <xsl:attribute name="href">/cgi-bin/koha/opac-detail.pl?biblionumber=<xsl:value-of select="$bibno"/></xsl:attribute>
222 <xsl:value-of select="$str"/>
225 <xsl:when test="boolean($index) and boolean(marc:subfield[@code=9])">
227 <xsl:attribute name="href">/cgi-bin/koha/opac-search.pl?q=an:<xsl:value-of select="marc:subfield[@code=9]"/></xsl:attribute>
228 <xsl:value-of select="$str"/>
231 <xsl:when test="boolean($index)">
233 <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>
234 <xsl:value-of select="$str"/>
238 <xsl:value-of select="$str"/>
249 <!-- Stylus Studio meta-information - (c)1998-2002 eXcelon Corp.
251 <scenarios/><MapperInfo srcSchemaPath="" srcSchemaRoot="" srcSchemaPathIsRelative="yes" srcSchemaInterpretAsXML="no" destSchemaPath="" destSchemaRoot="" destSchemaPathIsRelative="yes" destSchemaInterpretAsXML="no"/>