ga*****@aol.com (Gadrin77) writes:
what I really want to do is, once the above is done, change the comma
to a comma and space ", " so it looks good in the output. I've tried
Translate(Translate()) but that didn't seem to work.
As far as I can see translate() can not lengthen strings, so you
probably have to do full-blown search and replace which can be done
with a recursive template, as follows. You may decide it's not worth
the trouble 8^)
Your data
<Root>
<Main Value="Line1|Line2.|Line3|Line4.|Line5"/>
</Root>
with this transformation
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" omit-xml-declaration="yes"/>
<!-- The main template -->
<xsl:template match="/Root">
<xsl:call-template name="replace">
<xsl:with-param name="text" select="translate(Main/@Value, '.', '')"/>
<xsl:with-param name="from" select="'|'"/>
<xsl:with-param name="with" select="', '"/>
</xsl:call-template>
</xsl:template>
<!-- This is a recursive named template for search and replace. -->
<xsl:template name="replace">
<xsl:param name="text"/>
<xsl:param name="from"/>
<xsl:param name="with"/>
<xsl:choose>
<xsl:when test="$from and contains($text,$from)">
<xsl:value-of select="substring-before($text,$from)"/>
<xsl:value-of select="$with"/>
<xsl:call-template name="replace">
<xsl:with-param name="text" select="substring-after($text,$from)"/>
<xsl:with-param name="from" select="$from"/>
<xsl:with-param name="with" select="$with"/>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$text"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
</xsl:stylesheet>
gives the desired output:
Line1, Line2, Line3, Line4, Line5
Ben
--
Ben Edgington
Mail to the address above is discarded.
Mail to ben at that address might be read.
http://www.edginet.org/