3 <!DOCTYPE stylesheet [<!ENTITY nbsp " " >]>
5 <xsl:stylesheet version="1.0" xmlns:marc="http://www.loc.gov/MARC21/slim" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
6 <xsl:template name="datafield">
7 <xsl:param name="tag"/>
8 <xsl:param name="ind1"><xsl:text> </xsl:text></xsl:param>
9 <xsl:param name="ind2"><xsl:text> </xsl:text></xsl:param>
10 <xsl:param name="subfields"/>
11 <xsl:element name="datafield">
12 <xsl:attribute name="tag">
13 <xsl:value-of select="$tag"/>
15 <xsl:attribute name="ind1">
16 <xsl:value-of select="$ind1"/>
18 <xsl:attribute name="ind2">
19 <xsl:value-of select="$ind2"/>
21 <xsl:copy-of select="$subfields"/>
25 <xsl:template name="subfieldSelect">
26 <xsl:param name="codes"/>
27 <xsl:param name="delimeter"><xsl:text> </xsl:text></xsl:param>
28 <xsl:param name="subdivCodes"/>
29 <xsl:param name="subdivDelimiter"/>
30 <xsl:param name="prefix"/>
31 <xsl:param name="suffix"/>
32 <xsl:variable name="str">
33 <xsl:for-each select="marc:subfield">
34 <xsl:if test="contains($codes, @code)">
35 <xsl:if test="contains($subdivCodes, @code)">
36 <xsl:value-of select="$subdivDelimiter"/>
38 <xsl:value-of select="$prefix"/><xsl:value-of select="text()"/><xsl:value-of select="$suffix"/><xsl:value-of select="$delimeter"/>
42 <xsl:value-of select="substring($str,1,string-length($str)-string-length($delimeter))"/>
45 <xsl:template name="buildSpaces">
46 <xsl:param name="spaces"/>
47 <xsl:param name="char"><xsl:text> </xsl:text></xsl:param>
48 <xsl:if test="$spaces>0">
49 <xsl:value-of select="$char"/>
50 <xsl:call-template name="buildSpaces">
51 <xsl:with-param name="spaces" select="$spaces - 1"/>
52 <xsl:with-param name="char" select="$char"/>
57 <xsl:template name="buildBiblioDefaultViewURL">
58 <xsl:param name="IntranetBiblioDefaultView"/>
60 <xsl:when test="$IntranetBiblioDefaultView='normal'">
61 <xsl:text>/cgi-bin/koha/catalogue/detail.pl?biblionumber=</xsl:text>
63 <xsl:when test="$IntranetBiblioDefaultView='isbd'">
64 <xsl:text>/cgi-bin/koha/catalogue/ISBDdetail.pl?biblionumber=</xsl:text>
66 <xsl:when test="$IntranetBiblioDefaultView='labeled_marc'">
67 <xsl:text>/cgi-bin/koha/catalogue/labeledMARCdetail.pl?biblionumber=</xsl:text>
69 <xsl:when test="$IntranetBiblioDefaultView='marc'">
70 <xsl:text>/cgi-bin/koha/catalogue/MARCdetail.pl?biblionumber=</xsl:text>
73 <xsl:text>/cgi-bin/koha/catalogue/detail.pl?biblionumber=</xsl:text>
78 <xsl:template name="chopPunctuation">
79 <xsl:param name="chopString"/>
80 <xsl:variable name="length" select="string-length($chopString)"/>
82 <xsl:when test="$length=0"/>
83 <xsl:when test="contains('.:,;/ ', substring($chopString,$length,1))">
84 <xsl:call-template name="chopPunctuation">
85 <xsl:with-param name="chopString" select="substring($chopString,1,$length - 1)"/>
88 <xsl:when test="not($chopString)"/>
89 <xsl:otherwise><xsl:value-of select="$chopString"/></xsl:otherwise>
91 <xsl:text> </xsl:text>
94 <!-- Function extractControlNumber is used to extract the control number (record number) from MARC tags 773/80/85 [etc.] subfield $w.
95 Parameter: control number string.
96 Assumes LOC convention: (OrgCode)recordNumber.
97 If OrgCode is not present, return full string.
98 Additionally, handle various brackets/parentheses. Chop leading and trailing spaces.
100 <xsl:template name="extractControlNumber">
101 <xsl:param name="subfieldW"/>
102 <xsl:variable name="tranW" select="translate($subfieldW,']})>','))))')"/>
104 <xsl:when test="contains($tranW,')')">
105 <xsl:value-of select="normalize-space(translate(substring-after($tranW,')'),'[]{}()<>',''))"/>
108 <xsl:value-of select="normalize-space($subfieldW)"/>
113 <xsl:template name="nameABCDQ">
114 <xsl:call-template name="chopPunctuation">
115 <xsl:with-param name="chopString">
116 <xsl:call-template name="subfieldSelect">
117 <xsl:with-param name="codes">aq</xsl:with-param>
120 <xsl:with-param name="punctuation">
121 <xsl:text>:,;/ </xsl:text>
124 <xsl:call-template name="termsOfAddress"/>
127 <xsl:template name="nameABCDN">
128 <xsl:for-each select="marc:subfield[@code='a']">
129 <xsl:call-template name="chopPunctuation">
130 <xsl:with-param name="chopString" select="."/>
133 <xsl:for-each select="marc:subfield[@code='b']">
134 <xsl:value-of select="."/>
136 <xsl:if test="marc:subfield[@code='c'] or marc:subfield[@code='d'] or marc:subfield[@code='n']">
137 <xsl:call-template name="subfieldSelect">
138 <xsl:with-param name="codes">cdn</xsl:with-param>
143 <xsl:template name="nameACDEQ">
144 <xsl:call-template name="subfieldSelect">
145 <xsl:with-param name="codes">acdeq</xsl:with-param>
149 <xsl:template name="termsOfAddress">
150 <xsl:if test="marc:subfield[@code='b' or @code='c']">
151 <xsl:call-template name="chopPunctuation">
152 <xsl:with-param name="chopString">
153 <xsl:call-template name="subfieldSelect">
154 <xsl:with-param name="codes">bc</xsl:with-param>
161 <!-- Function m880Select: Display Alternate Graphic Representation (MARC 880) for selected latin "base"tags
162 - should be called immediately before the corresonding latin tags are processed
163 - tags in right-to-left languages are displayed floating right
165 + basetags: display these tags if found in linkage section ( subfield 6) of tag 880
166 + codes: display these subfields codes
168 - class: wrap output in <span class="$class">...</span>
169 - label: prefix each(!) tag with label $label
170 - bibno: link to biblionumber $bibno
171 - 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.
173 - displays every field on a separate line (to switch between rtl and ltr)
175 (!) output might be empty
177 <xsl:template name="m880Select">
178 <xsl:param name="basetags"/> <!-- e.g. 100,700,110,710 -->
179 <xsl:param name="codes"/> <!-- e.g. abc -->
180 <xsl:param name="class"/> <!-- e.g. results_summary -->
181 <xsl:param name="label"/> <!-- e.g. Edition -->
182 <xsl:param name="bibno"/>
183 <xsl:param name="index"/> <!-- e.g. au -->
185 <xsl:for-each select="marc:datafield[@tag=880]">
186 <xsl:variable name="code6" select="marc:subfield[@code=6]"/>
187 <xsl:if test="contains(string($basetags), substring($code6,1,3))">
189 <xsl:if test="boolean($class)">
190 <xsl:attribute name="class"><xsl:value-of select="$class"/></xsl:attribute>
193 <!-- display right-to-left tags floating right of their left-to-right counterparts -->
194 <xsl:when test="substring($code6,10,2) ='/r'">
195 <xsl:attribute name="style">display:block; text-align:right; float:right; width:50%; padding-left:20px</xsl:attribute>
196 <xsl:attribute name="dir">rtl</xsl:attribute>
199 <xsl:attribute name="style">display:block; </xsl:attribute>
202 <xsl:if test="boolean($label)">
204 <xsl:value-of select="$label"/>
207 <xsl:variable name="str">
208 <xsl:for-each select="marc:subfield">
209 <xsl:if test="contains($codes, @code)">
210 <xsl:value-of select="text()"/>
211 <xsl:text> </xsl:text>
216 <xsl:when test="boolean($bibno)">
218 <xsl:attribute name="href">/cgi-bin/koha/opac-detail.pl?biblionumber=<xsl:value-of select="$bibno"/></xsl:attribute>
219 <xsl:value-of select="$str"/>
222 <xsl:when test="boolean($index) and boolean(marc:subfield[@code=9])">
224 <xsl:attribute name="href">/cgi-bin/koha/opac-search.pl?q=an:<xsl:value-of select="marc:subfield[@code=9]"/></xsl:attribute>
225 <xsl:value-of select="$str"/>
228 <xsl:when test="boolean($index)">
230 <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>
231 <xsl:value-of select="$str"/>
235 <xsl:value-of select="$str"/>
246 <!-- Stylus Studio meta-information - (c)1998-2002 eXcelon Corp.
248 <scenarios/><MapperInfo srcSchemaPath="" srcSchemaRoot="" srcSchemaPathIsRelative="yes" srcSchemaInterpretAsXML="no" destSchemaPath="" destSchemaRoot="" destSchemaPathIsRelative="yes" destSchemaInterpretAsXML="no"/>