Re: Problem with "except" operator
>> So the above are equivalent. > > I think not, Andrew ... Martin is correct.
How about "never use != where one side in a sequence could be empty" instead? Because the same problem will exist if one of the two arguments is absent. In this case there is no difference if the address is for a singleton or a set, if the result is empty, the comparison will be false, which may not be what you want.
<xsl:if test="value != 3">
... even when there may only be one <value> child, will still be false if that one child is absent. The stylesheet writer may want it to be true because there is no value that is equal to 3, which is to say:
<xsl:if test="not( value = 3 )">
In XSLT 2 I've heard some pundits say:
Never use "=" because of this problem, always use "eq" and "ne" when dealing with singletons and always use "some ... in" and "every ... in" when dealing with sets.
... but I'm still a fan of "=" and "!=", even if I mistype when rushing a volunteer answer on a mail list. You aren't the only one who gets caught out.
I hope this helps.
. . . . . . . . . . Ken
-- Upcoming hands-on XSLT, UBL & code list hands-on training classes: Brussels, BE 2009-03; Prague, CZ 2009-03, http://www.xmlprague.cz Training tools: Comprehensive interactive XSLT/XPath 1.0/2.0 video Video lesson: http://www.youtube.com/watch?v=PrNjJCh7Ppg&fmt=18 Video overview: http://www.youtube.com/watch?v=VTiodiij6gE&fmt=18 G. Ken Holman mailto:gkholman@xxxxxxxxxxxxxxxxxxxx Crane Softwrights Ltd. http://www.CraneSoftwrights.com/s/ Male Cancer Awareness Nov'07 http://www.CraneSoftwrights.com/s/bc Legal business disclaimers: http://www.CraneSoftwrights.com/legal
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