Subject: Re: [xsl] Formatting string From: "Mukul Gandhi" <gandhi.mukul@xxxxxxxxx> Date: Wed, 16 May 2007 22:41:59 +0530 |
<?xml version="1.0"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:template match="x"> <xsl:call-template name="formatString"> <xsl:with-param name="s" select="string" /> <xsl:with-param name="result" select="''" /> </xsl:call-template> </xsl:template>
<xsl:template name="formatString"> <xsl:param name="s" /> <xsl:param name="result" />
<xsl:choose> <xsl:when test="string-length($s) = 0"> <xsl:value-of select="$result" /> </xsl:when> <xsl:otherwise> <xsl:choose> <xsl:when test="(string-length($s) = string-length(string)) and contains($caps, substring($s, 1, 1))"> <xsl:call-template name="formatString"> <xsl:with-param name="s" select="substring($s, 2)" /> <xsl:with-param name="result" select="concat($result, substring($s, 1, 1))" /> </xsl:call-template> </xsl:when> <xsl:when test="contains($caps, substring($s, 1, 1))"> <xsl:call-template name="formatString"> <xsl:with-param name="s" select="substring($s, 2)" /> <xsl:with-param name="result" select="concat($result, ' ', substring($s, 1, 1))" /> </xsl:call-template> </xsl:when> <xsl:otherwise> <xsl:call-template name="formatString"> <xsl:with-param name="s" select="substring($s, 2)" /> <xsl:with-param name="result" select="concat($result, substring($s, 1, 1))" /> </xsl:call-template> </xsl:otherwise> </xsl:choose> </xsl:otherwise> </xsl:choose> </xsl:template>
<x> <string>BankOfAmerica</string> </x>
Hi All,
Is there any way to add a space before Capital letters of a string?
for example my input string is "BankersGuarantee" and I want the result as "Bankers Guarantee" Another example..... the input string is "BankOfAmerica" and I want the result as "Bank Of America"
Can anyone help me to implement the above logic in xsl.
Thanks in advance, Babu
-- Regards, Mukul Gandhi
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Formatting string, Dimitre Novatchev | Thread | RE: [xsl] Formatting string, Babu Eswaramoorthy |
Re: [xsl] Calling a java method in , Kai Hackemesser | Date | [xsl] Excluding certain nodes from , Andy Carr1 |
Month |