XSL if: test with multiple test conditions
xml, xslt
Solution
Thanks to @IanRoberts, I had to use the normalize-space function on my nodes to check if they were empty.
<xsl:if test="((node/ABC!='') and (normalize-space(node/DEF)='') and (normalize-space(node/GHI)=''))">
This worked perfectly fine.
</xsl:if>
Problem
I am trying to create a xsl condition to check if combinations of node are empty or not. I have tried below conditions but they do not work, does anyone have an idea as to how to get it working ``` <xsl:if test=" node/ABC!='' and node/DEF='' and node/GHI='' "> This does not work </xsl:if> ``` I have also tried ``` <xsl:when test="((node/ABC!='') and (node/DEF='') and (node/GHI=''))"> This does not work either.. </xsl:when> ``` And also tried ``` <xsl:if test="(node/ABC!='')> <xsl:if test="(node/DEF='')> <xsl:if test="(node/GHI='')"> Nope not working.. </xsl:if> </xsl:if> </xsl:if> ``` I, then tried with single xsl:if conditions, and below is the observation ``` <xsl:if test="node/ABC!=''> **This is working fine** </xsl:if> ``` However if i try to search for empty condition, i.e ``` <xsl:if test="node/ABC=''> **This does not work** </xsl:if> ``` Also, if i try with a == (double equal to), then it gives xslt error. i.e ``` <xsl:if test="node/ABC==''> ***This gives a compilation error*** </xsl:if> ``` I would like help in figuring out how to get my xsl:if test working to check for multiple conditions. [Edit] : Just to update here that the if condition where all the nodes are not empty works, it does not work when i try to check for any other node out of the three nodes that are empty. For eg : ``` <xsl:if test=" node/ABC!='' and node/DEF!='' and node/GHI!='' "> This condition works perfectly fine. </xsl:if> ```