You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何在XSL的if与when语句中添加not contain(不包含)判断条件

XSL判断逻辑修改实现

核心语法说明

XSL 中实现「变量不包含指定字符串」的判断规则为:not(contains(目标变量, '匹配字符串')),将该条件与原有校验规则通过and拼接即可满足需求。

1. 修改后的if语句

<xsl:if test="(($RegEmployee = 'true') or ($ExecEmployee = 'true')) and not(contains($customBonusSegName, 'ABC'))">

2. 修改后的when语句(对应block2变量完整代码)

<xsl:variable name="block2">
        <xsl:choose>
            <xsl:when test="($RegEmployee = 'true') or ($ExecEmployee = 'true') and not(contains($customBonusSegName, 'ABC'))">
                <xsl:value-of select="'true'" />
            </xsl:when>
        <xsl:otherwise> 
            <xsl:value-of select="'false'" />
        </xsl:otherwise>
        </xsl:choose>
</xsl:variable>

3. 不包含逻辑的独立变量写法(可选)

如果你需要单独封装「是否不包含ABC」的判断结果,可直接修改参考写法如下:

<xsl:variable name="BonusSubtitle">
<xsl:choose> 
<xsl:when test="not(contains($customBonusSegName,'ABC'))">
<xsl:value-of select="'True'"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="'False'"/>
</xsl:otherwise>
</xsl:choose>
</xsl:variable>

内容的提问来源于stack exchange,提问作者jimmy markus

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.10.07 10:21:01