Example config uses backendelementset
[yazproxy-moved-to-github.git] / etc / 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:variable name="str">
26                         <xsl:for-each select="marc:subfield">
27                                 <xsl:if test="contains($codes, @code)">
28                                         <xsl:value-of select="text()"/><xsl:value-of select="$delimeter"/>
29                                 </xsl:if>
30                         </xsl:for-each>
31                 </xsl:variable>
32                 <xsl:value-of select="substring($str,1,string-length($str)-string-length($delimeter))"/>
33         </xsl:template>
34
35         <xsl:template name="buildSpaces">
36                 <xsl:param name="spaces"/>
37                 <xsl:param name="char"><xsl:text> </xsl:text></xsl:param>
38                 <xsl:if test="$spaces>0">
39                         <xsl:value-of select="$char"/>
40                         <xsl:call-template name="buildSpaces">
41                                 <xsl:with-param name="spaces" select="$spaces - 1"/>
42                                 <xsl:with-param name="char" select="$char"/>
43                         </xsl:call-template>
44                 </xsl:if>
45         </xsl:template>
46
47         <xsl:template name="chopPunctuation">
48                 <xsl:param name="chopString"/>
49                 <xsl:variable name="length" select="string-length($chopString)"/>
50                 <xsl:choose>
51                         <xsl:when test="$length=0"/>
52                         <xsl:when test="contains('.:,;/ ', substring($chopString,$length,1))">
53                                 <xsl:call-template name="chopPunctuation">
54                                         <xsl:with-param name="chopString" select="substring($chopString,1,$length - 1)"/>
55                                 </xsl:call-template>
56                         </xsl:when>
57                         <xsl:when test="not($chopString)"/>
58                         <xsl:otherwise><xsl:value-of select="$chopString"/></xsl:otherwise>
59                 </xsl:choose>
60         </xsl:template>
61 </xsl:stylesheet><!-- Stylus Studio meta-information - (c)1998-2002 eXcelon Corp.
62 <metaInformation>
63 <scenarios/><MapperInfo srcSchemaPath="" srcSchemaRoot="" srcSchemaPathIsRelative="yes" srcSchemaInterpretAsXML="no" destSchemaPath="" destSchemaRoot="" destSchemaPathIsRelative="yes" destSchemaInterpretAsXML="no"/>
64 </metaInformation>
65 -->