Test = "" in boolean always returns true
Why
<xsl:if test="<XPATH to boolean value here>"> ... </xsl:if> ALWAYS returns true?
Since a boolean value can be 0, "false" and "true" by definition, ONLY to check the boolean value is to compare the strings with them. It may not be right.
test test works as if it were calling the boolean function. This feature does not work as you think. If its argument evaluates to node-set (which will be if you use the path as its argument), it will return true if node-set is not empty, and false otherwise. So effectively, you check for the existence of an element, not its value. If foo contains false ,
<xsl:if test="/path/to/foo"> will always evaluate to true, since what you are really asking in this test is "does this element exist?" and not "is the value of the element true?" And the element exists.
The rule that booleans must be true , false , 1 or 0 is part of the XML schema ( which they see ), not XPath, which knows nothing about this rule. (XPath 1.0, that is, XPath 2.0 / XQuery 1.0 has a function fn:boolean that can, that is, XML Schema, evaluate boolean values.) To determine if a value is true in XSLT, you must explicitly check it:
<xsl:if test="/path/to/foo = 'true' or /path/to/foo = '1'"> The xpath specification gives a boolean function. Thus, boolean (Value) will always return true or false.