Saxon is correct. In terms of the XSLT 1.0 specification,
$w is a result tree fragment, so the rules are given in 11.1
A result tree fragment is
treated equivalently to a node-set that contains just a single root node.
However, the operations permitted on a result tree fragment are a subset of
those permitted on a node-set. An operation is permitted on a result tree
fragment only if that operation would be permitted on a string (the operation on
the string may involve first converting the string to a number or boolean). In
particular, it is not permitted to use the
 operators on result tree fragments. When a permitted operation
is performed on a result tree fragment, it is performed exactly as it would be
on the equivalent node-set.
When a node-set is converted to a boolean, the result is
true if the node-set contains at least one node. So the boolean value of a
result tree fragment is always true. It is *not* correct to convert the node-set
to a string and then convert the string to a boolean.
The 2.0 spec is couched in different language but the
effect is the same.
As it happens, I read a couple of days ago that Xalan
"optimizes" <xsl:variable name="x"><xsl:value-of
select="abc"/></xsl:variable> to <xsl:variable name="x"
select="abc"/>. This "optimization" is incorrect, because the boolean value
is different in the two cases.
In practice it's nearly always better to use the form
<xsl:variable name="x" select="abc"/> - creating a result tree fragment
rather than a string is very inefficient. Saxon tries to optimize it too,
because (for reasons I have never understood) users will insist on writing the
more verbose and less efficient construct: but it optimizes it to something that
retains the semantics.
Saxon and Xalan execute this XSL differently.
finds the "xsl:when" test true; Xalan finds it false.
Xalan-J 2.7 (Interpreted) displays Puffins