<xsl:if>
tests an expression (like the if
in traditional languages). The result of the expression is evaluated as a Boolean.
In your case, the expression is an XPath selector (/employee/first-name[@id]
) - it will always return a node-set. Node-sets are evaluated as false
only when they are empty (e.g. no matching nodes found).
The expression could also be something like number(/employee/id)
. Now the expression result is a number, which is evaluated as false
if it is zero or NaN
, true
in all other cases.
Other values that are false
are the empty string ''
(true
in all other cases) and the result of false()
itself. Note that there also is a true()
function to return a Boolean true
.
Also note that the string 'false'
evaluates to true
, per the the described rule for strings.