| Subject: Re: [xsl] Choose variable From: Jeni Tennison <jeni@xxxxxxxxxxxxxxxx> Date: Tue, 1 Jul 2003 11:09:04 +0100 | 
Hi Ricardo,
> I have an element that I want to modify its value. For example when is 1
> I want 10, 2 -> 15, 3 ->25 and so on.
> How can I do that knowing that I use it on different places and I don't
> want to go putting "xsl:choose" on all of that places. It would be much
> code repeated.
> I've tried to put the value on a variable inside an "xsl:choose" but It
> is impossible to have many variables with the same name.
Instead of putting the variable inside the <xsl:choose>, put the
<xsl:choose> inside the variable:
  <xsl:variable name="newValue">
    <xsl:choose>
      <xsl:when test=". = 1">10</xsl:when>
      <xsl:when test=". = 2">15</xsl:when>
      <xsl:when test=". = 3">25</xsl:when>
      ...
    </xsl:choose>
  </xsl:variable>
and then reuse $newValue wherever you need it.
If you need it in different templates, on the other hand, then you
should create a separate template that contains the <xsl:choose> and
call that template whenever you need the relevant value; the value
itself won't be reused, but the code that calculates it can be. Let us
know if you want to see how to do that.
Cheers,
Jeni
---
Jeni Tennison
http://www.jenitennison.com/
 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
| Current Thread | 
|---|
| 
 | 
| <- Previous | Index | Next -> | 
|---|---|---|
| [xsl] Choose variable, Ricardo Saraiva | Thread | Re: [xsl] Choose variable, David Carlisle | 
| [no subject], David Carlisle | Date | Re: [xsl] Choose variable, David Carlisle | 
| Month |