[XSL-LIST Mailing List Archive Home]
[By Thread]
[By Date]
[Recent Entries]
[Reply To This Message]
Re: The operator '!=' returns false when one operand d
Subject: Re: The operator '!=' returns false when one operand doesn't exist
From: "Vasu Chakkera" <vasucv@xxxxxxxxxxx>
Date: Wed, 07 Aug 2002 18:02:08 +0000
|
The spec says so.. :)
This is the very reason why it is best advised not to use '!=' unless u are
100% sure what you want to do.You should instead use *not* ..
as in **not($x = 'text')**as opposed to **$x != 'text'**
the former is most likely to mean the intended meaning.
Vasu
From: Jerome Louvel <jerome_louvel@xxxxxxxx>
Reply-To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
To: XSL-List@xxxxxxxxxxxxxxxxxxxxxx
Subject: The operator '!=' returns false when one operand doesn't
exist
Date: Wed, 7 Aug 2002 08:32:17 -0700 (PDT)
Hi All,
We have an issue with the XPath '!=' operator that has
a strange behavior when one of its operand doesn't
exist in the instance document. It returns 'false"
when you would expect "true" or some kind of exception
to be raised.
Sample stylesheet:
------------------
<?xml version="1.0" encoding="UTF-8"?>
<xsl:transform version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<data>
<xsl:value-of select="/data/a != /data/b"/>
</data>
</xsl:template>
</xsl:transform>
Instance:
---------
<?xml version="1.0"?>
<data>
<a>10</a>
</data>
This transformation will return 'false'.
If you add <b>11</b> under element a, or even an empty
<b/>, the result is becoming 'true'.
Could somebody explain me why we get such a result
(with MSXML 4.0 as well as Xalan)?
Is there a simple way, extension function or XPath
expression to would make this work as "expected" (true
is one of this operand doesn't exist)?
Thanks for your help!
Jerome.
__________________________________________________
Do You Yahoo!?
Yahoo! Health - Feel better, live better
http://health.yahoo.com
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
_________________________________________________________________
Chat with friends online, try MSN Messenger: http://messenger.msn.com
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
|
PURCHASE STYLUS STUDIO ONLINE TODAY!
Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!
Download The World's Best XML IDE!
Accelerate XML development with our award-winning XML IDE - Download a free trial today!
Subscribe in XML format
RSS 2.0 |
|
Atom 0.3 |
|
|