Now compiles and generates doc
[yazproxy-moved-to-github.git] / etc / MARC21slimUtils.xsl
1 <?xml version='1.0'?>\r
2 <xsl:stylesheet version="1.0" xmlns:marc="http://www.loc.gov/MARC21/slim" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">\r
3         <xsl:template name="datafield">\r
4                 <xsl:param name="tag"/>\r
5                 <xsl:param name="ind1"><xsl:text> </xsl:text></xsl:param>\r
6                 <xsl:param name="ind2"><xsl:text> </xsl:text></xsl:param>\r
7                 <xsl:param name="subfields"/>\r
8                 <xsl:element name="datafield">\r
9                         <xsl:attribute name="tag">\r
10                                 <xsl:value-of select="$tag"/>\r
11                         </xsl:attribute>\r
12                         <xsl:attribute name="ind1">\r
13                                 <xsl:value-of select="$ind1"/>\r
14                         </xsl:attribute>\r
15                         <xsl:attribute name="ind2">\r
16                                 <xsl:value-of select="$ind2"/>\r
17                         </xsl:attribute>\r
18                         <xsl:copy-of select="$subfields"/>\r
19                 </xsl:element>\r
20         </xsl:template>\r
21 \r
22         <xsl:template name="subfieldSelect">\r
23                 <xsl:param name="codes"/>\r
24                 <xsl:param name="delimeter"><xsl:text> </xsl:text></xsl:param>\r
25                 <xsl:variable name="str">\r
26                         <xsl:for-each select="marc:subfield">\r
27                                 <xsl:if test="contains($codes, @code)">\r
28                                         <xsl:value-of select="text()"/><xsl:value-of select="$delimeter"/>\r
29                                 </xsl:if>\r
30                         </xsl:for-each>\r
31                 </xsl:variable>\r
32                 <xsl:value-of select="substring($str,1,string-length($str)-string-length($delimeter))"/>\r
33         </xsl:template>\r
34 \r
35         <xsl:template name="buildSpaces">\r
36                 <xsl:param name="spaces"/>\r
37                 <xsl:param name="char"><xsl:text> </xsl:text></xsl:param>\r
38                 <xsl:if test="$spaces>0">\r
39                         <xsl:value-of select="$char"/>\r
40                         <xsl:call-template name="buildSpaces">\r
41                                 <xsl:with-param name="spaces" select="$spaces - 1"/>\r
42                                 <xsl:with-param name="char" select="$char"/>\r
43                         </xsl:call-template>\r
44                 </xsl:if>\r
45         </xsl:template>\r
46 \r
47         <xsl:template name="chopPunctuation">\r
48                 <xsl:param name="chopString"/>\r
49                 <xsl:variable name="length" select="string-length($chopString)"/>\r
50                 <xsl:choose>\r
51                         <xsl:when test="$length=0"/>\r
52                         <xsl:when test="contains('.:,;/ ', substring($chopString,$length,1))">\r
53                                 <xsl:call-template name="chopPunctuation">\r
54                                         <xsl:with-param name="chopString" select="substring($chopString,1,$length - 1)"/>\r
55                                 </xsl:call-template>\r
56                         </xsl:when>\r
57                         <xsl:when test="not($chopString)"/>\r
58                         <xsl:otherwise><xsl:value-of select="$chopString"/></xsl:otherwise>\r
59                 </xsl:choose>\r
60         </xsl:template>\r
61 </xsl:stylesheet><!-- Stylus Studio meta-information - (c)1998-2002 eXcelon Corp.\r
62 <metaInformation>\r
63 <scenarios/><MapperInfo srcSchemaPath="" srcSchemaRoot="" srcSchemaPathIsRelative="yes" srcSchemaInterpretAsXML="no" destSchemaPath="" destSchemaRoot="" destSchemaPathIsRelative="yes" destSchemaInterpretAsXML="no"/>\r
64 </metaInformation>\r
65 -->