2 <xsl:stylesheet version="1.0" xmlns:marc="http://www.loc.gov/MARC21/slim" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
3 <xsl:template name="datafield">
4 <xsl:param name="tag"/>
5 <xsl:param name="ind1"><xsl:text> </xsl:text></xsl:param>
6 <xsl:param name="ind2"><xsl:text> </xsl:text></xsl:param>
7 <xsl:param name="subfields"/>
8 <xsl:element name="datafield">
9 <xsl:attribute name="tag">
10 <xsl:value-of select="$tag"/>
12 <xsl:attribute name="ind1">
13 <xsl:value-of select="$ind1"/>
15 <xsl:attribute name="ind2">
16 <xsl:value-of select="$ind2"/>
18 <xsl:copy-of select="$subfields"/>
22 <xsl:template name="subfieldSelect">
23 <xsl:param name="codes"/>
24 <xsl:param name="delimeter"><xsl:text> </xsl:text></xsl:param>
25 <xsl:param name="subdivCodes"/>
26 <xsl:param name="subdivDelimiter"/>
27 <xsl:param name="prefix"/>
28 <xsl:param name="suffix"/>
29 <xsl:variable name="str">
30 <xsl:for-each select="marc:subfield">
31 <xsl:if test="contains($codes, @code)">
32 <xsl:if test="contains($subdivCodes, @code)">
33 <xsl:value-of select="$subdivDelimiter"/>
35 <xsl:value-of select="$prefix"/><xsl:value-of select="text()"/><xsl:value-of select="$suffix"/><xsl:value-of select="$delimeter"/>
39 <xsl:value-of select="substring($str,1,string-length($str)-string-length($delimeter))"/>
42 <xsl:template name="buildSpaces">
43 <xsl:param name="spaces"/>
44 <xsl:param name="char"><xsl:text> </xsl:text></xsl:param>
45 <xsl:if test="$spaces>0">
46 <xsl:value-of select="$char"/>
47 <xsl:call-template name="buildSpaces">
48 <xsl:with-param name="spaces" select="$spaces - 1"/>
49 <xsl:with-param name="char" select="$char"/>
54 <xsl:template name="chopPunctuation">
55 <xsl:param name="chopString"/>
56 <xsl:variable name="length" select="string-length($chopString)"/>
58 <xsl:when test="$length=0"/>
59 <xsl:when test="contains('.:,;/ ', substring($chopString,$length,1))">
60 <xsl:call-template name="chopPunctuation">
61 <xsl:with-param name="chopString" select="substring($chopString,1,$length - 1)"/>
64 <xsl:when test="not($chopString)"/>
65 <xsl:otherwise><xsl:value-of select="$chopString"/></xsl:otherwise>
67 <xsl:text> </xsl:text>
70 <xsl:template name="nameABCDQ">
71 <xsl:call-template name="chopPunctuation">
72 <xsl:with-param name="chopString">
73 <xsl:call-template name="subfieldSelect">
74 <xsl:with-param name="codes">aq</xsl:with-param>
77 <xsl:with-param name="punctuation">
78 <xsl:text>:,;/ </xsl:text>
81 <xsl:call-template name="termsOfAddress"/>
84 <xsl:template name="nameABCDN">
85 <xsl:for-each select="marc:subfield[@code='a']">
86 <xsl:call-template name="chopPunctuation">
87 <xsl:with-param name="chopString" select="."/>
90 <xsl:for-each select="marc:subfield[@code='b']">
91 <xsl:value-of select="."/>
93 <xsl:if test="marc:subfield[@code='c'] or marc:subfield[@code='d'] or marc:subfield[@code='n']">
94 <xsl:call-template name="subfieldSelect">
95 <xsl:with-param name="codes">cdn</xsl:with-param>
100 <xsl:template name="nameACDEQ">
101 <xsl:call-template name="subfieldSelect">
102 <xsl:with-param name="codes">acdeq</xsl:with-param>
106 <xsl:template name="termsOfAddress">
107 <xsl:if test="marc:subfield[@code='b' or @code='c']">
108 <xsl:call-template name="chopPunctuation">
109 <xsl:with-param name="chopString">
110 <xsl:call-template name="subfieldSelect">
111 <xsl:with-param name="codes">bc</xsl:with-param>
118 <!-- Function m880Select: Display Alternate Graphic Representation (MARC 880) for selected latin "base"tags
119 - should be called immediately before the corresonding latin tags are processed
120 - tags in right-to-left languages are displayed floating right
122 + basetags: display these tags if found in linkage section ( subfield 6) of tag 880
123 + codes: display these subfields codes
125 - class: wrap output in <span class="$class">...</span>
126 - label: prefix each(!) tag with label $label
127 - bibno: link to biblionumber $bibno
128 - 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.
130 - displays every field on a separate line (to switch between rtl and ltr)
132 (!) output might be empty
134 <xsl:template name="m880Select">
135 <xsl:param name="basetags"/> <!-- e.g. 100,700,110,710 -->
136 <xsl:param name="codes"/> <!-- e.g. abc -->
137 <xsl:param name="class"/> <!-- e.g. results_summary -->
138 <xsl:param name="label"/> <!-- e.g. Edition -->
139 <xsl:param name="bibno"/>
140 <xsl:param name="index"/> <!-- e.g. au -->
142 <xsl:for-each select="marc:datafield[@tag=880]">
143 <xsl:variable name="code6" select="marc:subfield[@code=6]"/>
144 <xsl:if test="contains(string($basetags), substring($code6,1,3))">
146 <xsl:if test="boolean($class)">
147 <xsl:attribute name="class"><xsl:value-of select="$class"/></xsl:attribute>
150 <!-- display right-to-left tags floating right of their left-to-right counterparts -->
151 <xsl:when test="substring($code6,10,2) ='/r'">
152 <xsl:attribute name="style">display:block; text-align:right; float:right; width:50%; padding-left:20px</xsl:attribute>
153 <xsl:attribute name="dir">rtl</xsl:attribute>
156 <xsl:attribute name="style">display:block; </xsl:attribute>
159 <xsl:if test="boolean($label)">
161 <xsl:value-of select="$label"/>
164 <xsl:variable name="str">
165 <xsl:for-each select="marc:subfield">
166 <xsl:if test="contains($codes, @code)">
167 <xsl:value-of select="text()"/>
168 <xsl:text> </xsl:text>
173 <xsl:when test="boolean($bibno)">
175 <xsl:attribute name="href">/cgi-bin/koha/opac-detail.pl?biblionumber=<xsl:value-of select="$bibno"/></xsl:attribute>
176 <xsl:value-of select="$str"/>
179 <xsl:when test="boolean($index) and boolean(marc:subfield[@code=9])">
181 <xsl:attribute name="href">/cgi-bin/koha/opac-search.pl?q=an:<xsl:value-of select="marc:subfield[@code=9]"/></xsl:attribute>
182 <xsl:value-of select="$str"/>
185 <xsl:when test="boolean($index)">
187 <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>
188 <xsl:value-of select="$str"/>
192 <xsl:value-of select="$str"/>
203 <!-- Stylus Studio meta-information - (c)1998-2002 eXcelon Corp.
205 <scenarios/><MapperInfo srcSchemaPath="" srcSchemaRoot="" srcSchemaPathIsRelative="yes" srcSchemaInterpretAsXML="no" destSchemaPath="" destSchemaRoot="" destSchemaPathIsRelative="yes" destSchemaInterpretAsXML="no"/>