A very simple solution (that will work as long as your string value doesn't have spaces):
translate(normalize-space(translate('aa::bb::cc',':',' ')),' ',',')
- translate ":' into " "
normalize-space()
to collapse multiple whitespace characters into a single space " "
- translate single spaces " " into ","
A more robust solution would be to use a recursive template:
<xsl:template name="replace-string">
<xsl:param name="text"/>
<xsl:param name="replace"/>
<xsl:param name="with"/>
<xsl:choose>
<xsl:when test="contains($text,$replace)">
<xsl:value-of select="substring-before($text,$replace)"/>
<xsl:value-of select="$with"/>
<xsl:call-template name="replace-string">
<xsl:with-param name="text"
select="substring-after($text,$replace)"/>
<xsl:with-param name="replace" select="$replace"/>
<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>
You can use it like this:
<xsl:call-template name="replace-string">
<xsl:with-param name="text" select="'aa::bb::cc'"/>
<xsl:with-param name="replace" select="'::'" />
<xsl:with-param name="with" select="','"/>
</xsl:call-template>
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…