O
Oleg Konovalov
Hi,
I am new to XSLT, trying to significantly modify somebody
else's XSL. That is not 2.0.
I need to create min & max variable(s)
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 [that's not XSLT
2.0]:
<xsl:variable min><call-template name="calculate-min"/></xsl:variable>
2) how to declare a global variable and then assign it much later in the
code;
3) Also, it there a way to compare a node value with a previous
value within a for-each loop like (to find a max value of the nodes):
<xsl:for-each mystruct/mystuct1>
<xsl:if test="position() > 1 and
var2 > var2(position()-1)">...do something...
</xsl:if>
</xsl:for-each>
Would that work ?
4) Can I get access to a value from another branch
from within for-each (where var2 and var3 are "brothers")?
Like:
<xsl:for-each mystruct/mystruct1>
<xsl:if test="var2 > ../var3">...do something...
</xsl:if>
</xsl:for-each>)
Any help is very appreciated.
Thank you in advance,
Oleg
I am new to XSLT, trying to significantly modify somebody
else's XSL. That is not 2.0.
I need to create min & max variable(s)
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 [that's not XSLT
2.0]:
<xsl:variable min><call-template name="calculate-min"/></xsl:variable>
2) how to declare a global variable and then assign it much later in the
code;
3) Also, it there a way to compare a node value with a previous
value within a for-each loop like (to find a max value of the nodes):
<xsl:for-each mystruct/mystuct1>
<xsl:if test="position() > 1 and
var2 > var2(position()-1)">...do something...
</xsl:if>
</xsl:for-each>
Would that work ?
4) Can I get access to a value from another branch
from within for-each (where var2 and var3 are "brothers")?
Like:
<xsl:for-each mystruct/mystruct1>
<xsl:if test="var2 > ../var3">...do something...
</xsl:if>
</xsl:for-each>)
Any help is very appreciated.
Thank you in advance,
Oleg