加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

xml – XSLT替换功能未找到

发布时间:2020-12-16 07:53:17 所属栏目:百科 来源:网络整理
导读:我正在编写一个XSLT转换,其中我希望使用Replace函数来进行正则表达式匹配和替换. 但Visual Studio 2008报告 ‘replace()’ is an unknown XSLT function. 代码本身就是: xsl:otherwise td style="border: solid 1px black; background-color:#00CC66;" xsl:
我正在编写一个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>

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读