2 <!DOCTYPE stylesheet [
<!ENTITY nbsp
" " >]
>
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"/>
14 <xsl:attribute name=
"ind1">
15 <xsl:value-of select=
"$ind1"/>
17 <xsl:attribute name=
"ind2">
18 <xsl:value-of select=
"$ind2"/>
20 <xsl:copy-of select=
"$subfields"/>
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"/>
34 <xsl:value-of select=
"substring($str,1,string-length($str)-string-length($delimeter))"/>
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"/>
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)"/>
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"/>
61 <xsl:when test=
"not($chopString)"/>
62 <xsl:otherwise><xsl:value-of select=
"$chopString"/></xsl:otherwise>
66 <xsl:template name=
"chopPunctuationFront">
67 <xsl:param name=
"chopString"/>
68 <xsl:variable name=
"length" select=
"string-length($chopString)"/>
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)"/>
76 <xsl:when test=
"not($chopString)"/>
77 <xsl:otherwise><xsl:value-of select=
"$chopString"/></xsl:otherwise>