xsl-list
[Top] [All Lists]

Re: [xsl] Assigning value to variable based on xsl:choose test

2006-07-24 02:11:02
Hi David,

I think what you want to do is putting the test inside the variable. Like this:

<xsl:variable name="numTickets">
   <xsl:choose>
       <xsl:when test="price_type = 56">8</xsl:when>
       <xsl:when test="price_type = 57">4</xsl:when>
       <xsl:otherwise>9</xsl:otherwise>
   </xsl:choose>
</xsl:variable>

This way you can use the variable $numTickets inside any other function in the same scope, or global scope if you defined the variable on root level.

Cheers,
Abel Braaksma
Nuntia B.V.

David Murphy wrote:

Hello

Is it possible to set the value of a variable based upon a test?

My first effort is below, and I also tried to assign the value to the
variable using xsl:attribute but that doesn't work either.

<xsl:choose>
        <xsl:when test="price_type = 56"><xsl:variable name="numTickets"
select="8"/></xsl:when>
        <xsl:when test="price_type = 57"><xsl:variable name="numTickets"
select="4"/></xsl:when>
        <xsl:otherwise><xsl:variable name="numTickets"
select="9"/></xsl:otherwise>
</xsl:choose>

...

<xsl:call-template name="counter">
     <xsl:with-param name="max" select="$numTickets"/>
</xsl:call-template>


I'm guessing that one cannot assign values to variables inline like
this, but I've not managed to get it working so a bit of guidance that
will help me work this out would be much appreciated.

Regards, David

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--






--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--

<Prev in Thread] Current Thread [Next in Thread>