but I cannot figure ...">

How to check the condition of logical equality in XSLT?

I have this simple test in XSLT

<xsl:if test="isTrue = 'false'"> 

but I cannot figure out how to make the logical equality operator here. I know that < is &lt; and > is &gt; So what is the logical equality operator for XSLT? I tried &eq; &et; == and = , or is it for XSLT you can only compare numbers?

+7
source share
1 answer

= should work just fine

for example this xml entry

 <xml> <SomeElement>1</SomeElement> <SomeAttribute attr="true" /> </xml> 

Through this conversion:

 <?xml version="1.0" ?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:template match="/xml"> <xsl:if test="SomeElement=1"> Some Element is 1 </xsl:if> <xsl:if test="SomeAttribute/@attr='true'"> Some Attribute is true </xsl:if> </xsl:template> </xsl:stylesheet> 

Returns

 Some Element is 1 Some Attribute is true 

As expected. Is there a possible error in the path selector, and not in test ?

+11
source

Source: https://habr.com/ru/post/1496886/


All Articles