/ Published in: XSLT
Convert a string into upper lower case. So
hello world = Hello World
hello world = Hello World
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
<xsl:template name="ToUpperLowerCase"> <xsl:param name="inputString"/> <xsl:param name="index"/> <xsl:param name="loopCount"/> <xsl:if test="$index < $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>
URL: http://groups.google.com/group/xml-and-xslt/browse_thread/thread/0b2b3a8350262213#