XSL の「contains」ディレクティブはありますか? 質問する

XSL の「contains」ディレクティブはありますか? 質問する

次の 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>

contains の構文を理解できなかったため、if ステートメントは機能しません。xsl:if を正しく表現するにはどうすればよいでしょうか?

ベストアンサー1

もちろんあります!例えば:

<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)

おすすめ記事