是否有 XSL“包含"?指示? [英] Is there an XSL "contains" directive?

查看:22
本文介绍了是否有 XSL“包含"?指示?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下 XSL 片段:

I have the following snippet of XSL:

  <xsl:for-each select="item">
    <xsl:variable name="hhref" select="link" />
    <xsl:variable name="pdate" select="pubDate" />
    <xsl:if test="hhref not contains '1234'">
      <li>
        <a href="{$hhref}" title="{$pdate}">
          <xsl:value-of select="title"/>
        </a>
      </li>
    </xsl:if>
  </xsl:for-each>

if 语句不起作用,因为我无法计算出 contains 的语法.我将如何正确表达 xsl:if?

The if statement does not work because I haven't been able to work out the syntax for contains. How would I correctly express that xsl:if?

推荐答案

当然有!例如:

<xsl:if test="not(contains($hhref, '1234'))">
  <li>
    <a href="{$hhref}" title="{$pdate}">
      <xsl:value-of select="title"/>
    </a>
  </li>
</xsl:if>

语法为:contains(stringToSearchWithin, stringToSearchFor)

这篇关于是否有 XSL“包含"?指示?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆