Fix a problem when translations contain   various XSL files
[koha.git] / koha-tmpl / intranet-tmpl / prog / en / xslt / MARC21slimUtils2.xsl
blob8998b53fea40f2e7213bb643a6e6612f67ed1b6f
1 <?xml version='1.0'?>
2 <!DOCTYPE stylesheet [<!ENTITY nbsp "&#160;" >]>
3 <xsl:stylesheet version="1.0" xmlns:marc="http://www.loc.gov/MARC21/slim" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
4 <!-- 8/19/04: ntra added "marc:" prefix to datafield element -->
5 <xsl:template name="datafield">
6 <xsl:param name="tag"/>
7 <xsl:param name="ind1"><xsl:text> </xsl:text></xsl:param>
8 <xsl:param name="ind2"><xsl:text> </xsl:text></xsl:param>
9 <xsl:param name="subfields"/>
10 <xsl:element name="marc:datafield">
11 <xsl:attribute name="tag">
12 <xsl:value-of select="$tag"/>
13 </xsl:attribute>
14 <xsl:attribute name="ind1">
15 <xsl:value-of select="$ind1"/>
16 </xsl:attribute>
17 <xsl:attribute name="ind2">
18 <xsl:value-of select="$ind2"/>
19 </xsl:attribute>
20 <xsl:copy-of select="$subfields"/>
21 </xsl:element>
22 </xsl:template>
24 <xsl:template name="subfieldSelect">
25 <xsl:param name="codes"/>
26 <xsl:param name="delimeter"><xsl:text> </xsl:text></xsl:param>
27 <xsl:variable name="str">
28 <xsl:for-each select="marc:subfield">
29 <xsl:if test="contains($codes, @code)">
30 <xsl:value-of select="text()"/><xsl:value-of select="$delimeter"/>
31 </xsl:if>
32 </xsl:for-each>
33 </xsl:variable>
34 <xsl:value-of select="substring($str,1,string-length($str)-string-length($delimeter))"/>
35 </xsl:template>
37 <xsl:template name="buildSpaces">
38 <xsl:param name="spaces"/>
39 <xsl:param name="char"><xsl:text> </xsl:text></xsl:param>
40 <xsl:if test="$spaces>0">
41 <xsl:value-of select="$char"/>
42 <xsl:call-template name="buildSpaces">
43 <xsl:with-param name="spaces" select="$spaces - 1"/>
44 <xsl:with-param name="char" select="$char"/>
45 </xsl:call-template>
46 </xsl:if>
47 </xsl:template>
49 <xsl:template name="chopPunctuation">
50 <xsl:param name="chopString"/>
51 <xsl:param name="punctuation"><xsl:text>.:,;/ </xsl:text></xsl:param>
52 <xsl:variable name="length" select="string-length($chopString)"/>
53 <xsl:choose>
54 <xsl:when test="$length=0"/>
55 <xsl:when test="contains($punctuation, substring($chopString,$length,1))">
56 <xsl:call-template name="chopPunctuation">
57 <xsl:with-param name="chopString" select="substring($chopString,1,$length - 1)"/>
58 <xsl:with-param name="punctuation" select="$punctuation"/>
59 </xsl:call-template>
60 </xsl:when>
61 <xsl:when test="not($chopString)"/>
62 <xsl:otherwise><xsl:value-of select="$chopString"/></xsl:otherwise>
63 </xsl:choose>
64 </xsl:template>
66 <xsl:template name="chopPunctuationFront">
67 <xsl:param name="chopString"/>
68 <xsl:variable name="length" select="string-length($chopString)"/>
69 <xsl:choose>
70 <xsl:when test="$length=0"/>
71 <xsl:when test="contains('.:,;/[ ', substring($chopString,1,1))">
72 <xsl:call-template name="chopPunctuationFront">
73 <xsl:with-param name="chopString" select="substring($chopString,2,$length - 1)"/>
74 </xsl:call-template>
75 </xsl:when>
76 <xsl:when test="not($chopString)"/>
77 <xsl:otherwise><xsl:value-of select="$chopString"/></xsl:otherwise>
78 </xsl:choose>
79 </xsl:template>
80 </xsl:stylesheet>