Subject: Re: [xsl] value of variable inside a condition doesn't work? From: "Hubert Holtz" <Turnhose_alt@xxxxxxx> Date: Tue, 28 Jan 2003 21:05:30 +0100 |
Thanks to Joerg and John and all others, works fine. Homer30 *********** REPLY SEPARATOR *********** On 28.01.2003 at 20:20 Joerg Heinicke wrote: >Hello Hubert, > >you have two errors in your code: > >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> > >The variables are out of scope. In scope means they are only used in >descendants of its parent. So outside your <xsl:if/> they are out of scope. > >Change it to: > ><xsl:variable name="stadt"> > <xsl:if test="$lang=1">city</xsl:if> ></xsl:variable> > >With this approach you don't make the second error. ><xsl:variable name="stadt" select="city"/> means, that you are searching >for the text value of a child node with name 'city'. But you want a >string, which must be written as select="'city'"/>. > >With my above solution you have a result tree fragment in your variable, >that is converted into a string when using <xsl:value-of select="$stadt"/>. > >Regards, > >Joerg > >> <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 XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] value of variable inside , Joerg Heinicke | Thread | Re: [xsl] value of variable inside , Ritu |
RE: [xsl] value of variable inside , cknell | Date | Re: [xsl] value of variable inside , S Woodside |
Month |