From: Mark Neves [mailto:Mark.Neves@Xitec-Software.com]
Sent: September 27, 2001 07:49
Subject: [saxon] When "not($Var=@att)" differs from "$Var!=@att"
It appears that the following two statements are not always the same:
Attached are 3 files that illustrate the problem, test.xml, test.xsl (which works), and test2.xsl (which doesn't work)
<xsl:variable name="LastDir" select="preceding-sibling::KEY/@direction"/>
<xsl:value-of select="concat(' ',@direction,' KEY')"/>
<xsl:value-of select="concat(' ',@name)"/>
<KEY direction="ASCENDING" name="AK1"/>
<KEY direction="ASCENDING" name="AK2"/>
<KEY direction="DESCENDING" name="DK1"/>
Using Instant Saxon, the command "saxon test.xml test.xsl" gives:
ASCENDING KEY AK1 AK2 DESCENDING KEY DK1
which is correct. The clause "not($LastDir=@direction)" successfully detects that when LastDir is empty, it is not equal to the value of the current node's "direction" attribute.
However, using test2.xsl, which contains the line <xsl:if test="$LastDir!=@direction"> gives
AK1 AK2 DESCENDING KEY DK1
i.e. when LastDir is empty, "$LastDir!=@direction" equates to False
I've tried Saxon versions 6.2.2, 6.4.3 and 6.4.4, and they all behave the same way.
Is this a bug, or is there a subtlety I'm unaware of?
<<test.xml>> <<test.xsl>> <<test2.xsl>>