[xsl] Using a parameter in a condition

Subject: [xsl] Using a parameter in a condition
From: Ian Lang <ianplang@xxxxxxxxx>
Date: Mon, 23 Feb 2004 23:11:59 -0800 (PST)
I am implementing a look up table for localizable
strings.  I have a string table that looks like this:
<?xml version="1.0"?>
  <string key="String.One">First String</string>
  <string key="String.Two">Second String</string>

I do this to load the string table in my main xslt:
  <!-- Load the string table -->
  <xsl:variable name="stringTable"
where $stringTableFileName is a parameter to the style

To test things I used variables like this:
<xsl:variable name="title"

Which worked but I wanted to instead call a template
passing it the key so I can centralize the lookup and
provide the ability to return a string "!<key>!" if
the key could not be found.  So I wrote:
  <xsl:template name="getLocalizedString">
    <xsl:param name="key"/>
    <xsl:variable name="lookupString"
      <xsl:when test="lookupString != ''">
        <!-- Return the found string -->
        <xsl:value-of select="$lookupString"/>
        <!-- Return a string indicating what key could
not be found -->

The trouble is that no matter how I write the
definition for lookupString and no matter how I pass
the parameter key I cannot get it to work.  I either
get returns of "!!" or "!<key>!" but never the string
I want.  This seems like and FAQ but I cannot seemt to
find what I am looking for.

Any help apprciated,


Do you Yahoo!?
Yahoo! Mail SpamGuard - Read only the mail you want.

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list

Current Thread