Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: [xsl] Having Trouble With Condition For Default Nodeset Selection

From: Duncan Anker <danker@------------->
To:
Date: 7/5/2006 12:43:00 AM
Hi Ken,



Thanks for the nerf mallet. Your suggested solution seems to do the 
trick quite nicely.



On the use of "//",  the $currency-data comes from a 
select="document(..)"  and so seems to be required or I get no result 
set - although I can probably fold the currency-data and codes into a 
single select. Better pass me that mallet again. :)



Regards,
Duncan

G. Ken Holman wrote:
In your case, using the not() in the predicate will be true for those 
members that are not the value of the country code, therefore it will 
be true for many members.  So, you need a predicate that will only be 
true when the member is not found.



I think I would use something along the lines of:



<!--are you sure you need "//" in the following?-->
<xsl:variable name="codes"
              select="$currency-data//currency"/>
<xsl:variable name="found-code"
              select="$codes[@code = $country-code]"/>
<xsl:variable name="currency"
              select="$found-code |
                      $codes[@code='US'][not( $found-code )]"/>

I hope this helps.



. . . . . . . . . Ken



At 2006-07-05 09:57 +1000, Duncan Anker wrote:
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?
--
Duncan Anker
Server 101, Web Hosting & E-Commerce
http://www.server101.com


transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent