替换xslt中的字符串

问题描述:

我正在使用xslt1.0。我输入替换xslt中的字符串

<xsl:variable name="string">width:12pt;border-width:13pt</xsl:variable> 

我想更换-width:进入其他字符串,但不宽(宽开始 - 本身就应该更换)。如何做到这一点在XSLT 1.0。

+0

可能重复[找不到XSLT替换功能(http://stackoverflow.com/questions/1069092/xslt-replace-function-not-found) – 2011-04-01 15:20:24

XSLT 1.0中没有替换函数。你可以找到here (String.Replace() in XSLT)一个可以做到这一点的模板。

您可以使用它像这样:

<xsl:variable name="string"> 
    <xsl:call-template name="string-replace-all"> 
    <xsl:with-param name="text" select="width:12pt;border-width:13pt" /> 
    <xsl:with-param name="replace" select="-width" /> 
    <xsl:with-param name="by" select="other-string" /> 
    </xsl:call-template> 
</xsl:variable>