You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@xalan.apache.org by Morten Jorgensen <mo...@ireland.sun.com> on 2001/05/29 12:49:26 UTC
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