[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

RE: [xsl] splitting a string at ,

Subject: RE: [xsl] splitting a string at ,
From: Ryan Graham <Ryan.Graham@xxxxxxxxxxxxx>
Date: Wed, 14 Jan 2004 16:46:17 -0700

>I have a string seperated with commas. I am trying to
>split the string at commas.
>How can this be done.

I know this is not the most elegant solution, but it works:

Given this source XML-


This stylesheet snippet...

<xsl:template match="foo">
	<xsl:call-template name="splitString">
		<xsl:with-param name="string1" select="."/>
<xsl:template name="splitString">
	<xsl:param name="string1"/>
		<xsl:when test="contains($string1,',')">
			<xsl:variable name="beforeComma"
			<xsl:element name="entry"><xsl:value-of
			<xsl:variable name="afterComma"
			<xsl:call-template name="splitString">
				<xsl:with-param name="string1"
select="$afterComma" />
			<xsl:element name="entry">
				<xsl:value-of select="$string1"/>

...produces the following output:


Of course you can modify this to suit your personal requirements.



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

Current Thread