DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Snippets has posted 5883 posts at DZone. View Full User Profile

Uppecase First

04.24.2005
| 5164 views |
  • submit to reddit
        <!--
*** ucfirst
*** Make a string's first character uppercase
*** Param str = the string
-->
-
	<xsl:stylesheet version="1.0">
-
	<xsl:template match="/">
<xsl:param name="string" select="'the quick brown fox jumped over the lazy dog.'"/>
-
	<xsl:call-template name="ucfirst">
<xsl:with-param name="str" select="$string"/>
</xsl:call-template>
</xsl:template>
-
	<xsl:template name="ucfirst">
<xsl:param name="str"/>
<xsl:param name="strLen" select="string-length($str)"/>
<xsl:variable name="firstLetter" select="substring($str,1,1)"/>
<xsl:variable name="restString" select="substring($str,2,$strLen)"/>
<xsl:variable name="lower" select="'abcdefghijklmnopqrstuvwxyz'"/>
<xsl:variable name="upper" select="'ABCDEFGHIJKLMNOPQRSTUVWXYZ'"/>
<xsl:variable name="translate" select="translate($firstLetter,$lower,$upper)"/>
<xsl:value-of select="concat($translate,$restString)"/>
</xsl:template>
</xsl:stylesheet>