2 <xsl:stylesheet version="1.0" xmlns:marc="http://www.loc.gov/MARC21/slim" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
3 <!-- 8/19/04: ntra added "marc:" prefix to datafield element -->
4 <xsl:template name="datafield">
5 <xsl:param name="tag"/>
6 <xsl:param name="ind1"><xsl:text> </xsl:text></xsl:param>
7 <xsl:param name="ind2"><xsl:text> </xsl:text></xsl:param>
8 <xsl:param name="subfields"/>
9 <xsl:element name="marc:datafield">
10 <xsl:attribute name="tag">
11 <xsl:value-of select="$tag"/>
13 <xsl:attribute name="ind1">
14 <xsl:value-of select="$ind1"/>
16 <xsl:attribute name="ind2">
17 <xsl:value-of select="$ind2"/>
19 <xsl:copy-of select="$subfields"/>
23 <xsl:template name="subfieldSelect">
24 <xsl:param name="codes">abcdefghijklmnopqrstuvwxyz</xsl:param>
25 <xsl:param name="delimeter"><xsl:text> </xsl:text></xsl:param>
26 <xsl:variable name="str">
27 <xsl:for-each select="marc:subfield">
28 <xsl:if test="contains($codes, @code)">
29 <xsl:value-of select="text()"/><xsl:value-of select="$delimeter"/>
33 <xsl:value-of select="substring($str,1,string-length($str)-string-length($delimeter))"/>
36 <xsl:template name="buildSpaces">
37 <xsl:param name="spaces"/>
38 <xsl:param name="char"><xsl:text> </xsl:text></xsl:param>
39 <xsl:if test="$spaces>0">
40 <xsl:value-of select="$char"/>
41 <xsl:call-template name="buildSpaces">
42 <xsl:with-param name="spaces" select="$spaces - 1"/>
43 <xsl:with-param name="char" select="$char"/>
48 <xsl:template name="chopPunctuation">
49 <xsl:param name="chopString"/>
50 <xsl:param name="punctuation"><xsl:text>.:,;/ </xsl:text></xsl:param>
51 <xsl:variable name="length" select="string-length($chopString)"/>
53 <xsl:when test="$length=0"/>
54 <xsl:when test="contains($punctuation, substring($chopString,$length,1))">
55 <xsl:call-template name="chopPunctuation">
56 <xsl:with-param name="chopString" select="substring($chopString,1,$length - 1)"/>
57 <xsl:with-param name="punctuation" select="$punctuation"/>
60 <xsl:when test="not($chopString)"/>
61 <xsl:otherwise><xsl:value-of select="$chopString"/></xsl:otherwise>
65 <xsl:template name="chopPunctuationFront">
66 <xsl:param name="chopString"/>
67 <xsl:variable name="length" select="string-length($chopString)"/>
69 <xsl:when test="$length=0"/>
70 <xsl:when test="contains('.:,;/[ ', substring($chopString,1,1))">
71 <xsl:call-template name="chopPunctuationFront">
72 <xsl:with-param name="chopString" select="substring($chopString,2,$length - 1)"/>
75 <xsl:when test="not($chopString)"/>
76 <xsl:otherwise><xsl:value-of select="$chopString"/></xsl:otherwise>