Re: [xsl] Testing if all child nodes match (based on the value of certain elements)

Subject: Re: [xsl] Testing if all child nodes match (based on the value of certain elements)
From: David Carlisle <davidc@xxxxxxxxx>
Date: Mon, 23 Apr 2007 22:26:30 +0100
> Did you never use something like:
> 
> somenode[position() != 1]

Yes, but (some of the time) I know what I'm doing. The semantics of !=
when both operands are atomic values, as in your example, are useful,
in fact they are the same as not(position() = 1) so the only advantage
to != is that it saves 4 characters. If one operand is atomic and the
other is a node set, != is less useful, and if they are both node sets
then != is almost never useful (this thread being the exception).
99 times out of a hundred when a beginner uses != the stylesheet does
the wrong thing and not(...=...) was intended. Rather than try to
remember the circumstances in which it's safe to use != I think it's
simpler just to always use not (..= ..) (although, as you suggest above,
I don't always follow my own advice).

David

Current Thread