Return to Snippet

Revision: 16383
at August 2, 2009 16:14 by Meander365


Initial Code
<xsl:template name="ToUpperLowerCase">
                <xsl:param name="inputString"/>
                <xsl:param name="index"/>
                <xsl:param name="loopCount"/>
                <xsl:if test="$index &lt; $loopCount">
                        <xsl:choose>
                                <xsl:when test="substring($inputString, ($index)-1,1) = ' ' or $index = 1">
                                        <xsl:call-template name="ToUpper">
                                                <xsl:with-param name="inputString" select="substring($inputString,$index,1)"/>
                                        </xsl:call-template>
                                </xsl:when>
                                <xsl:otherwise>
                                        <xsl:call-template name="ToLower">
                                                <xsl:with-param name="inputString" select="substring($inputString,$index,1)"/>
                                        </xsl:call-template>
                                </xsl:otherwise>
                        </xsl:choose>
                        <xsl:call-template name="ToUpperLowerCase">
                                <xsl:with-param name="inputString" select="$inputString"/>
                                <xsl:with-param name="index" select="($index)+1"/>
                                <xsl:with-param name="loopCount" select="$loopCount"/>
                        </xsl:call-template>
                </xsl:if>
        </xsl:template>

        <xsl:template name="ToLower">
                <xsl:param name="inputString"/>
                <xsl:variable name="smallCase" select="'abcdefghijklmnopqrstuvwxyz'"/

                <xsl:variable name="upperCase" select="'ABCDEFGHIJKLMNOPQRSTUVWXYZ'"/

                <xsl:value-of select="translate($inputString,$upperCase,$smallCase)"/>
        </xsl:template>

        <xsl:template name="ToUpper">
                <xsl:param name="inputString"/>
                <xsl:variable name="smallCase" select="'abcdefghijklmnopqrstuvwxyz'"/

                <xsl:variable name="upperCase" select="'ABCDEFGHIJKLMNOPQRSTUVWXYZ'"/

                <xsl:value-of select="translate($inputString,$smallCase,$upperCase)"/

        </xsl:template>

Initial URL
http://groups.google.com/group/xml-and-xslt/browse_thread/thread/0b2b3a8350262213#

Initial Description
Convert a string into upper lower case. So

hello world = Hello World

Initial Title
Convert String to Upper Lower Case in XSL

Initial Tags

                                

Initial Language
XSLT