我有以下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)
确实有一个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)