You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@xalan.apache.org by Ma...@nokia.com on 2001/05/29 13:20:28 UTC

RE: little off-topic / setting value of a variable as consequence of some tests

hi,
	sorry for not replying to the list
since i should have an output like
<element1>value-of variable1</element1>
<element2>value-of variable2</element2>

i solved the question by calling two different templates, one that output
the value of the variable and
the other that insteand output null as value of variable

sorry all

regards
	marco

> -----Original Message-----
> From: ext Morten Jorgensen [mailto:morten.jorgensen@ireland.sun.com]
> Sent: 29. May 2001 13:49
> To: Marco.Mistroni@nokia.com
> Cc: xalan-dev@xml.apache.org
> Subject: Re: little off-topic / setting value of a variable as
> consequenceof some tests
> 
> 
> Marco,
> 
> I can't think of a way of doing that - I doubt that it is
> possible. The only possible way I can come up with is to
> first put two values into one variable:
> 
>   <xsl:variable name="twoinone">
>     <!-- assign value to first part of variable -->
>     <xsl:if test="first-test">true</xsl:if>
>     <xsl:otherwise>false</xsl:otherwise>
>     <!-- use '/' to separate the values -->
>     <xsl:text>/</xsl:text>
>     <!-- assign value to second part of variable -->
>     <xsl:if test="second-test">true</xsl:if>
>     <xsl:otherwise>false</xsl:otherwise>
>   </xsl:variable>
> 
> and then break the two values apart:
> 
>   <xsl:variable name="first" 
> select="substring-before($twoinone,'/')"/>
>   <xsl:variable name="second" 
> select="substring-after($twoinone,'/')"/>
> 
> Not very elegant, but I think it should work.
> 
> Morten
> 
> Marco.Mistroni@nokia.com wrote:
> > 
> > hi mr jorgensen,
> >         thanx a lot...it worked....
> > now i have litte more complex thing to do....
> > how can i set TWO variables as a result of some tests?
> > 
> > hope u can help me once more
> > regards
> >         marco
> > 
> > > -----Original Message-----
> > > From: ext Morten Jorgensen 
[mailto:morten.jorgensen@ireland.sun.com]
> > Sent: 29. May 2001 12:54
> > To: xalan-dev@xml.apache.org
> > Subject: Re: little off-topic / setting value of a variable as
> > consequence of some tests
> >
> >
> > Marco,
> >
> > Hello again! Put the if/otherwise elements inside the variable
> > declaration:
> >
> >   <xsl:variable name="myvariable> <!-- no 'select' -->
> >     <xsl:if test="starts-with(./@name,'mar')">
> >       <!-- assign value to variable here -->
> >     </xsl:if>
> >     <xsl:otherwise/> <!-- assign nothing to variable -->
> >   </xsl:variable>
> >
> > I am not sure this will work with all XSLT processors, but it
> > should...
> >
> > Morten