[解决了]
感谢@IanRoberts,我不得不在节点上使用normalize-space函数来检查它们是否为空.
<xsl:if test="((node/ABC!='') and (normalize-space(node/DEF)='') and (normalize-space(node/GHI)=''))">
This worked perfectly fine.
</xsl:if>
Run Code Online (Sandbox Code Playgroud)
[问题]
我正在尝试创建一个xsl条件来检查节点的组合是否为空.我尝试过以下条件,但它们不起作用,是否有人知道如何使其正常工作
<xsl:if test=" node/ABC!='' and node/DEF='' and node/GHI='' ">
This does not work
</xsl:if>
Run Code Online (Sandbox Code Playgroud)
我也试过了
<xsl:when test="((node/ABC!='') and (node/DEF='') and (node/GHI=''))">
This does not work either..
</xsl:when>
Run Code Online (Sandbox Code Playgroud)
并尝试过
<xsl:if test="(node/ABC!='')>
<xsl:if test="(node/DEF='')>
<xsl:if test="(node/GHI='')">
Nope not working..
</xsl:if>
</xsl:if>
</xsl:if>
Run Code Online (Sandbox Code Playgroud)
我,然后用单个xsl尝试:如果条件,以下是观察
<xsl:if test="node/ABC!=''>
**This is working fine**
</xsl:if>
Run Code Online (Sandbox Code Playgroud)
但是,如果我尝试搜索空条件,即
<xsl:if test="node/ABC=''>
**This does not work**
</xsl:if>
Run Code Online (Sandbox Code Playgroud)
此外,如果我尝试使用==(双等于),那么它会给出xslt错误.即
<xsl:if test="node/ABC==''>
***This gives a compilation error***
</xsl:if>
Run Code Online (Sandbox Code Playgroud)
我想帮助弄清楚如何获取我的xsl:如果测试工作以检查多个条件.提前致谢.
[编辑]:只是为了更新这里所有节点都不为空的if条件工作,当我尝试检查三个空节点中的任何其他节点时,它不起作用.
例如:
<xsl:if test=" node/ABC!='' and node/DEF!='' and node/GHI!='' ">
This condition works perfectly fine.
</xsl:if>
Run Code Online (Sandbox Code Playgroud)
noo*_*ode 22
感谢@IanRoberts,我不得不在节点上使用normalize-space函数来检查它们是否为空.
<xsl:if test="((node/ABC!='') and (normalize-space(node/DEF)='') and (normalize-space(node/GHI)=''))">
This worked perfectly fine.
</xsl:if>
Run Code Online (Sandbox Code Playgroud)
只是为了完整起见,那些不知道 XSL 1 可以选择多种条件的人。
<xsl:choose>
<xsl:when test="expression">
... some output ...
</xsl:when>
<xsl:when test="another-expression">
... some output ...
</xsl:when>
<xsl:otherwise>
... some output ....
</xsl:otherwise>
</xsl:choose>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
157665 次 |
| 最近记录: |