fix DOS newlines in MARC21slimUtils.xsl
[koha.git] / koha-tmpl / opac-tmpl / prog / en / xslt / MARC21slimUtils.xsl
1 <?xml version='1.0'?>
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"/>
11                         </xsl:attribute>
12                         <xsl:attribute name="ind1">
13                                 <xsl:value-of select="$ind1"/>
14                         </xsl:attribute>
15                         <xsl:attribute name="ind2">
16                                 <xsl:value-of select="$ind2"/>
17                         </xsl:attribute>
18                         <xsl:copy-of select="$subfields"/>
19                 </xsl:element>
20         </xsl:template>
21
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:variable name="str">
28                         <xsl:for-each select="marc:subfield">
29                                 <xsl:if test="contains($codes, @code)">
30                     <xsl:if test="contains($subdivCodes, @code)">
31                         <xsl:value-of select="$subdivDelimiter"/>
32                     </xsl:if>
33                                         <xsl:value-of select="text()"/><xsl:value-of select="$delimeter"/>
34                                 </xsl:if>
35                         </xsl:for-each>
36                 </xsl:variable>
37                 <xsl:value-of select="substring($str,1,string-length($str)-string-length($delimeter))"/>
38         </xsl:template>
39
40         <xsl:template name="buildSpaces">
41                 <xsl:param name="spaces"/>
42                 <xsl:param name="char"><xsl:text> </xsl:text></xsl:param>
43                 <xsl:if test="$spaces>0">
44                         <xsl:value-of select="$char"/>
45                         <xsl:call-template name="buildSpaces">
46                                 <xsl:with-param name="spaces" select="$spaces - 1"/>
47                                 <xsl:with-param name="char" select="$char"/>
48                         </xsl:call-template>
49                 </xsl:if>
50         </xsl:template>
51
52         <xsl:template name="chopPunctuation">
53                 <xsl:param name="chopString"/>
54                 <xsl:variable name="length" select="string-length($chopString)"/>
55                 <xsl:choose>
56                         <xsl:when test="$length=0"/>
57                         <xsl:when test="contains('.:,;/ ', substring($chopString,$length,1))">
58                                 <xsl:call-template name="chopPunctuation">
59                                         <xsl:with-param name="chopString" select="substring($chopString,1,$length - 1)"/>
60                                 </xsl:call-template>
61                         </xsl:when>
62                         <xsl:when test="not($chopString)"/>
63                         <xsl:otherwise><xsl:value-of select="$chopString"/></xsl:otherwise>
64                 </xsl:choose>
65         </xsl:template>
66 </xsl:stylesheet><!-- Stylus Studio meta-information - (c)1998-2002 eXcelon Corp.
67 <metaInformation>
68 <scenarios/><MapperInfo srcSchemaPath="" srcSchemaRoot="" srcSchemaPathIsRelative="yes" srcSchemaInterpretAsXML="no" destSchemaPath="" destSchemaRoot="" destSchemaPathIsRelative="yes" destSchemaInterpretAsXML="no"/>
69 </metaInformation>
70 -->