cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Oleg Konovalov <>
Subject Initializing variables in XSLT
Date Thu, 12 May 2005 22:24:37 GMT

I am new to XSLT, trying to significantly modify somebody
else's XSL.

I need to create min and max variables 
to be used in many templates and sub-templates
based on certain conditions (not always).

It can't be calculated at the beginning of the file
(depends on other variables),
so seems like it has to be made local variable(s).

Since it's not easy to calculate (20-50 lines of code each)
probably makes sense to make a template out of it.

What I don't know is:
1) how to make template to return a value,
something like:
  min = <call-template name="calculate-min"/>

2) how to declare variable and then assign it much later
in the code;

3) Also, it there a way to compare a value and a previous
value within a for-each loop like:
<xsl:for-each mystruct/myvar1>
  <xsl:if test="position() &gt; 1  and
    var2 &gt; var2(position()-1)"> something...
Would that work ?

4) Can I get access to a value from another branch
from within for-each ?
<xsl:for-each mystruct/myvar1>
  <xsl:if test="var2 &gt; ../var3"> something...

Any help is very appreciated.

Thank you in advance,

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message