Oops, that last loop in my previous e-mail was wrong,
it should be like:
<xsl:for-each mystruct/myvar1[i]/myvar>
  <xsl:if test="number(var2) &gt;
number(../../myvar2[i]/myvar/var3)">
   ...do something...
  </xsl:if>
</xsl:for-each>)

Would that work ?

All the best,
Oleg.

--- Conal Tuohy <[EMAIL PROTECTED]> wrote:
> Oleg Konovalov wrote:
> 
> > I am new to XSLT, trying to significantly modify somebody
> else's XSL.
> 
> You should ask these XSLT questions on the Mulberry XSL list.
> If you are
> new to XSL you'll find it invaluable.
> 
> > I need to create min and max variables
> > to be used in many templates and sub-templates based on 
> > certain conditions (not always).
> 
> See the Functional XSL project:
> http://fxsl.sourceforge.net/articles/FuncProg/2.html#minimum
> 
> > What I don't know is:
> > 1) how to make template to return a value, something like:
> >   min = <call-template name="calculate-min"/>
> 
> <xsl:variable name="min"><xsl:call-template
> name="calculate-min"/></xsl:variable>
> 
> > 2) how to declare variable and then assign it much later in
> the code;
> 
> You have to declare and assign in the same place. Variables in
> XSLT are
> not really "variable" :-)
> They are like static final variables in Java.
> 
> > 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)">...do something...
> >   </xsl:if>
> > </xsl:for-each>
> > Would that work ?
> 
> If "...do something" is supposed to re-assign the value of the
> "min"
> variable, then no, you can't work this way, because you can't
> modify the
> value of a variable. You can do something like this by
> recursing,
> though, so you have multiple instances of a variable on a
> stack (hence
> you're not changing it's value, just hiding it by introducing
> a new
> variable binding in a more local scope).
> 
> > 4) Can I get access to a value from another branch from 
> > within for-each ?
> > Like:
> > <xsl:for-each mystruct/myvar1>
> >   <xsl:if test="var2 &gt; ../var3">...do something...
> >   </xsl:if>
> > </xsl:for-each>) 
> 
> I'm not entirely clear on what you mean. I think so.
> 
> Anyway ... try the Mulberry XSL list, it's much better for
> pure XSL
> questions.
> 
> Regards
> 
> Con
> 
>
---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to