xsl-list
[Top] [All Lists]

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

2006-07-04 17:21:59
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[(_at_)code = $country-code]"/>
<xsl:variable name="currency"
              select="$found-code |
                      $codes[(_at_)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[(_at_)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?

:{)}


--
Registration open for UBL training:    Montréal, Canada 2006-08-07
Also for XSL-FO/XSLT training:    Minneapolis, MN 2006-07-31/08-04
Also for UBL/XML/XSLT/XSL-FO training: Varo,Denmark 06-09-25/10-06
World-wide corporate, govt. & user group UBL, XSL, & XML training.
G. Ken Holman                 mailto:gkholman(_at_)CraneSoftwrights(_dot_)com
Crane Softwrights Ltd.          http://www.CraneSoftwrights.com/s/
Box 266, Kars, Ontario CANADA K0A-2E0    +1(613)489-0999 (F:-0995)
Male Cancer Awareness Aug'05  http://www.CraneSoftwrights.com/s/bc
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>
--~--