[XSL-LIST Mailing List Archive Home]
[By Thread]
[By Date]
[Recent Entries]
[Reply To This Message]
Re: Having Trouble With Condition For Default Nodeset
Subject: Re: Having Trouble With Condition For Default Nodeset Selection
From: Duncan Anker <danker@xxxxxxxxxxxxx>
Date: Thu, 6 Jul 2006 21:55:56 +1000
|
On 05/07/2006, at 19:30, Michael Kay wrote:
I think you're making the old mistake of writing @code != 'US' when
you mean
not(@code = 'US').
If there's no @code attribute, the first expression returns false
(because
there is no code that is not equal to 'US'), while the second
returns true.
Thanks for the clarification, Michael, that was quite helpful.
Intuitively, I was fairly certain there is a difference between A !=
B and not(A=B) but I wasn't able to wrap my head around it enough to
follow it through. I am probably thinking too much in terms of
boolean logic where they are the same thing, and still coming to
terms with the set theory which is so prevalent in XSLT.
Ken's solution worked for me, so happily I didn't need to do my head
in thinking about it :)
Generally in XSLT, there are very few cases where A!=B is correct and
not(A=B) is wrong.
Michael Kay
http://www.saxonica.com/
-----Original Message-----
From: Duncan Anker [mailto:danker@xxxxxxxxxxxxx]
Sent: 05 July 2006 00:57
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject: Having Trouble With Condition For Default
Nodeset Selection
Hi Folks,
I am trying to look up a country code in a list of supported
currencies, with a default to US if it is not found. I am
using the XSLT 1.0 idiom of
nodeset1[condition] | nodeset2[not(condition)]
for a mutually exclusive result, however for the life of me I
can't seem to find a suitable condition - I probably just
need a figurative whack on the side of the head to help me
"think different" (or should that be "differently?"). I have
tried several different variations of the following with no
luck, though I am probably just overlooking something really obvious:
<xsl:variable name="currency"
select="$currency-data//currency[@code=$country-code and
@code != 'US']
| $currency-data//currency[not(@code=$country-code and @code
!= 'US')]"
| />
Nothing seems to work no matter how I arrange that - the US
currency is always unioned into the set. I'm sure that's the
wrong condition to use, and there is something relatively
simple I can add, but I'm just not seeing it.
Does anyone have any suggestions, or perhaps a nerf mallet?
Thanks in advance
--
Duncan Anker
Server 101, Web Hosting & E-Commerce
http://www.server101.com
|
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 |
|
|