At 2012-12-25 12:19 -0700, Mark Wilson wrote:
I am trying to modify a sort-select statement I worked out a very
long time ago. In the original, I wanted not to sort by a <Prefix>
if it were an 'A' and this code does just that:
<xsl:sort select="if( Prefix!='A' ) then Prefix else ''"/>
I am not sure why its positive version does not work:
<xsl:sort select="if( Prefix='A' ) then '' else Prefix"/>
Those two expressions are not polar opposites because at least one of
the operands is a node set.
This is an important issue that I bring up in the classroom because
of the confusion of dealing with node sets.
The result of the comparison is initialized as false() and then the
comparisons begin with members of the node set. If the node set is
empty, there are no comparisons and so false() is returned.
So, if you have an element Prefix, then "Prefix != 'A'" returns
true() if, say, Prefix has the value 'B'. But, "Prefix != 'A'"
returns false() if there are no Prefix elements. One might think
that that expression returning false() would imply that there is a
Prefix and it has the value 'A'. It doesn't in this example (though
it would be true if, in fact, there were a Prefix and it has the
value 'A'). This is not intuitive and you need to know about how
comparisons work with node sets.
The polar opposite of "Prefix = 'A'" is "not( Prefix = 'A')".
I have no idea what is going on and would appreciate any help I can get.
I hope this helps explain your situation.
And a Merry Christmas to you and other readers who celebrate it!
. . . . . . . . Ken
--
Contact us for world-wide XML consulting and instructor-led training
Free 5-hour lecture: http://www.CraneSoftwrights.com/links/udemy.htm
Crane Softwrights Ltd. http://www.CraneSoftwrights.com/s/
G. Ken Holman mailto:gkholman(_at_)CraneSoftwrights(_dot_)com
Google+ profile: https://plus.google.com/116832879756988317389/about
Legal business disclaimers: http://www.CraneSoftwrights.com/legal
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--