RE: [xsl] find capital letters in string and split it

Subject: RE: [xsl] find capital letters in string and split it
From: "bryan" <bry@xxxxxxxxxx>
Date: Tue, 11 Feb 2003 10:44:55 +0100
As an aside this is what I got to last night before Dimitre came with
the fxsl solution, problem of course is that it won't handle single
letter words:



<xsl:template match="string">
	<xsl:variable name="splitIDbig" select="normalize-
space(translate(.,'ABCDEFGHIJKLMNOPQRSTUVWXYZ','                        
	'))"/>
	<xsl:variable name="splitIDsmall" select="normalize-
space(translate(.,'abcdefghijklmnopqrstuvwxyz','                        
	'))"/>
	<xsl:variable name="mingle">
		<xsl:call-template name="mingler">
		<xsl:with-param name="splitIDbig" select="normalize-
space($splitIDbig)"/>
		<xsl:with-param name="splitIDsmall" select="normalize-
space($splitIDsmall)"/>
		</xsl:call-template>
	</xsl:variable>

<result>
	<xsl:value-of select="$mingle"/>
</result>
</xsl:template>

<xsl:template name="mingler">
	<xsl:param name="splitIDbig"/>
	<xsl:param name="splitIDsmall"/>
	<xsl:param name="result"/>
		<xsl:choose>
			<xsl:when test="string-length($splitIDsmall)
&gt; 0">
			<xsl:variable name="tempstring">
				<xsl:choose>
				<xsl:when
test="substring-before($splitIDsmall,'')">
				<xsl:value-of 
	
select="concat($result,substring-before($splitIDsmall,'
'),substring-before($splitIDbig,' '),' ')"/>
				</xsl:when>
				<xsl:otherwise>
				<xsl:value-of
select="concat($result,$splitIDsmall,$splitIDbig)"/>
				</xsl:otherwise>
				</xsl:choose>
				</xsl:variable>
				<xsl:call-template name="mingler">
				<xsl:with-param name="splitIDbig"
select="substring-				after($splitIDbig,'
')"/>
				<xsl:with-param name="splitIDsmall"
select="substring-after($splitIDsmall,' ')"/>
				<xsl:with-param name="result"
select="$tempstring"/>
				</xsl:call-template>
				</xsl:when>
				<xsl:otherwise>
				<xsl:value-of select="$result"/>
				</xsl:otherwise>
				</xsl:choose>
</xsl:template>


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread