我有一些特殊字符的URL,我想替換它們,我使用xslt 1.0,所以我寫的代碼如下。xslt1.0替換不起作用
<xsl:template name="string-replace-all">
<xsl:param name="text"/>
<xsl:param name="replace"/>
<xsl:param name="by"/>
<xsl:choose>
<xsl:when test="contains($text,$replace)">
<xsl:value-of select="substring-before($text,$replace)"/>
<xsl:value-of select="$by"/>
<xsl:call-template name="string-replace-all">
<xsl:with-param name="text" select="substring-after($text,$replace)"/>
<xsl:with-param name="replace" select="$replace"/>
<xsl:with-param name="by" select="$by"/>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$text"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
,並呼籲像這樣:
<td class="ms-vb">
<xsl:variable name="link">
<xsl:call-template name="string-replace-all">
<xsl:with-param name="text" select="@FileRef"/>
<xsl:with-param name="replace" select="'''"/>
<xsl:with-param name="by" select="'%27'"/>
</xsl:call-template>
</xsl:variable>-->
<a target="_blank" href="@link" ><xsl:value-of select="@New_x0020_Doc_x0020_Title" disable-output-escaping="yes" /></a>
</td>
我收到錯誤 「Web部件無法顯示」。任何人都可以請建議我在這裏做錯了什麼?
好問題(+1)。請參閱我的答案以獲得解釋和完整解 – 2010-08-06 18:41:26