XSLT variable/param question

D

darel.finkbeiner

I want to do this:

<xsl:template>
<xsl:choose>
<xsl:when>
Calculate a value.
<xsl:eek:therwise>
Calculate a value differently
</xsl:choose>
Use the value I calculated in a couple of different places
</xsl:template>

I can't wrap my head around how to do this. I'm desperate to do this
whole thing in XSLT, but I'm despairing that it may just not be
possible.

Is there a solution that would accomplish something like this?
 
J

Joseph Kesselman

The trick that most beginners miss is that you need to turn this inside
out -- since XSL variables are single-assignment, you need to think in
terms of computing a conditional value rather than conditionally
computing a value. For example:

<xsl:variable name="foo">
<xsl:choose>
<xsl:when>
Calculate a value.
<xsl:eek:therwise>
Calculate a value differently
</xsl:choose>
</xsl:variable>

rather than trying to do separate variable assignments in the two
branches of the choose.
 
D

Darel Finkbeiner

That is genius.

I can't thank you enough. That helps me not only in this current
situation, but helps me understand XSLT even better. I appreciate it.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

Forum statistics

Threads
474,007
Messages
2,570,266
Members
46,865
Latest member
AveryHamme

Latest Threads

Top