要在 xsl 裡做字串取代, 有2個方法, 參考看看下面的範例:
1. translate
translate(string,':',', ')
2. 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>
call template example:
<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>
資料來源:
xslt 1.0 string replace function
http://stackoverflow.com/questions/7520762/xslt-1-0-string-replace-function
Replace
http://www.dpawson.co.uk/xsl/sect2/replace.html#d8766e61

沒有留言:
張貼留言