前端之家收集整理的这篇文章主要介绍了
xml – XSLT替换功能未找到,
前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
@H_
403_0@
我正在编写一个XSLT转换,其中我希望使用Replace
函数来进行正则表达式匹配和替换.
但Visual Stu@R_404_410@ 2008报告
‘replace()’ is an unknown XSLT function.
代码本身就是:
<xsl:otherwise>
<td style="border: solid 1px black; background-color:#00CC66;">
<xsl:variable name="FeatureInfo" select="Text" />
<xsl:value-of select="replace($FeatureInfo,'Feature=','TESTING')"/>
</td>
</xsl:otherwise>
有什么我做错了吗?
谢谢 :)
编辑:我使用这个版本的XSLT,但它看起来像是Visual Stu@R_404_410@的版本是一个问题…我必须尝试找到一个解决方法.
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
替换
功能仅适用于XSLT 2.0版,而不是版本1.0
which is what Visual Studio uses.只因为您指定version =“2.0”并不意味着Visual Stu@R_
404_410@
支持它.
你应该可以使用它,但我不能保证其效率.
(从上面的链接)
<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>
你会这样称呼:
<xsl:otherwise>
<td style="border: solid 1px black; background-color:#00CC66;">
<xsl:variable name="FeatureInfo" select="Text" />
<xsl:call-template name="string-replace-all">
<xsl:with-param name="text" select="$FeatureInfo"/>
<xsl:with-param name="replace" select="Feature="/>
<xsl:with-param name="by" select="TESTING"/>
</xsl:call-template>
</td>
</xsl:otherwise>