我正在编写一个XSLT转换,其中我希望使用Replace函数来进行正则表达式匹配和替换.
但Visual Studio 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 Studio的版本是一个问题…我必须尝试找到一个解决方法.
<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 Studio支持它.
你应该可以使用它,但我不能保证其效率.
(从上面的链接)
<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>
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。