[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

Re: [xsl] value of variable inside a condition doesn't work?


Subject: Re: [xsl] value of variable inside a condition doesn't work?
From: Rick Taylor <taylor@xxxxxxxx>
Date: Tue, 28 Jan 2003 12:25:06 -0700

You can put the conditional code inside the variable like this.

<xsl:variable name="stadt">
 <xsl:choose>
  <xsl:when test="$lang='1'">
   <xsl:value-of select="'Stadt'"/>
  </xsl:when>
  <xsl:when test="$lang='2'">
   <xsl:value-of select="'city'"/>
  </xsl:when>
 <xsl:choose>
</xsl:variable>

-rick

At 08:05 PM 1/28/03 +0100, Hubert Holtz wrote:
Hy,

first of all I know there is this <i18n> thing to make multilanguage sites, but that's not the topic.

I have enabled xslt-with-parameter in my sitemap, in my xsl file i have a global parameter 'lang' this is the parameter which should
contain the value of the equal url-parameter, so far so good.


Now I want to output text fragments in 2 languages, depending on this parameter, so I thought of sth. like this:

-- code --

<xsl:if test="($lang)='1' ">
    <xsl:variable name="stadt" select="Stadt"/>
     <xsl:variable name="Texteingabe" select="Hier Text eingeben"/>
    <xsl:variable name="berichtstatus" select="aktuell"/>
</xsl:if>

<xsl:if test="($lang)='2' ">
    <xsl:variable name="stadt" select="city"/>
    <xsl:variable name="Texteingabe" select="Please enter text"/>
    <xsl:variable name="berichtstatus" select="current"/>
</xsl:if>

..

<td><xsl:value-of select="$stadt"/></td>

-- code --


But I get an error message, that there is no 'stadt' variable, if I delete the <xsl.if> part then there is no error message, but then I can't change the
value of the variable depending on the 'lang' paramter, of course.


So could it be that variables can't be set in an if statement and if that's true what would be the solution?


thanks Homer30





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

Rick Taylor XML Developer PPDM Association


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




Current Thread
Keywords