Quote:
quote:Originally posted by Israr
There is not any solution to that till now
|
Hi All,
Here is a solution:
<xsl:template name="TitleCase">
<xsl:param name="text" />
<xsl:param name="lastletter" select="' '"/>
<xsl:if test="$text">
<xsl:variable name="thisletter" select="substring($text,1,1)"/>
<xsl:choose>
<xsl:when test="$lastletter=' '">
<xsl:value-of select="translate($thisletter,'abcdefghijklmnopqrs tuvwxyz','ABCDEFGHIJKLMNOPQRSTUVWXYZ')"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$thisletter"/>
</xsl:otherwise>
</xsl:choose>
<xsl:call-template name="TitleCase">
<xsl:with-param name="text" select="substring($text,2)"/>
<xsl:with-param name="lastletter" select="$thisletter"/>
</xsl:call-template>
</xsl:if>
</xsl:template>
Sample usage:
<xsl:call-template name="TitleCase">
<xsl:with-param name="text"
select="translate(normalize-space(text()),'ABCDEFGHIJKLMNOPQRSTUVWXYZ','abcdef ghijklmnopqrstuvwxyz')"/>
</xsl:call-template>
(Mailing list of apache has discussed about this while ago...)
Regards,
Mohan