是否有XSL"包含"指令?

Guy*_*Guy 54 xslt

我有以下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>
Run Code Online (Sandbox Code Playgroud)

if语句不起作用,因为我无法计算contains的语法.我怎样才能正确表达xsl:if?

Cer*_*rus 105

当然有!例如:

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

语法是: contains(stringToSearchWithin, stringToSearchFor)


Joh*_*ter 6

确实有一个xpath包含的函数应该看起来像:

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


Dim*_*hev 6

使用标准的XPath函数contains().

功能:布尔 包含(字符串,字符串)

包含如果第一个字符串参数包含第二个参数字符串函数返回true,否则返回false