如何在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
相关产品推荐
相关产品推荐

