[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Understanding Identity Transformations

Subject: Re: Understanding Identity Transformations
From: Dimitre Novatchev <dnovatchev@xxxxxxxxx>
Date: Sun, 13 Feb 2005 10:33:56 +1100
xsl not equal
What Mike is explaining here is something crucial.

Not understanding the difference in the behaviour on node-sets of the
"!="operator and the not() function causes enormous confusion to a
lots of XSLT programmers.

One of the most valuable advice from even the first edition of "XSLT
Programmer's Reference" is always to try to use "not()" and to use
"!=" only when it is really necessary.


Cheers,
Dimitre Novatchev


On Sat, 12 Feb 2005 22:00:49 -0000, Michael Kay <mike@xxxxxxxxxxxx> wrote:
> > > Wow.. that is easy except that I do not understand your notice
> > > explanation... the difference between your not( ... ) and your !=.
> >
> > "@cat != 'BLUE'": will be true if the context node has a
> > 'cat' attribute
> > *and* if it has a 'cat' attribute not equal to 'BLUE'. So
> > it's the same as
> > "boolean(@cat) and not(@cat='BLUE')"
> >
> > "not(@cat='BLUE')": will be true if the context node has no 'cat'
> > attribute *or* if it has a 'cat' attribute not equal to
> > 'BLUE'. So it's
> > equal to "not(@cat) or not(@cat='BLUE')"
> 
> Let's try to phrase it a different way. An expression such as X=Y in XPath
> is shorthand for
> 
> some $x in X, $y in Y satisfies $x=$y
> 
> in other words, it's true if there's some pair of values from the two sets
> that are equal.
> 
> Similarly, X!=Y is short for
> 
> some $x in X, $y in Y satisfies $x!=$y
> 
> which is true if there's some pair that are not equal.
> 
> This means that if X is an empty set, then X=3 and X!=3 must both be false.
> If you're testing an attribute, @A=3, then @A is a set that's either empty
> or contains one node. If there's no A attribute, then @A!=3 is false
> (because there's no A that's not equal to 3), but not(@A=3) is true (because
> it's not true that there's an A that's equal to 3).
> 
> Michael Kay
> http://www.saxonica.com/

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.