I’m working on XSLT 1.0 version I have declared an int variable that have to increase when one (if condition) condition in true.
So can anyone tell me how to increament that variable or any soluton to that?
e.g.
<xsl:variable name="count" select="-1" />
is a variable declared. Then after that I’m checking one condition
<xsl:if test="$serviceP=$new">
// if condition id true the i have to increment the variable value (i.e count).
//and again have compare that count varibale value in if condition
<xsl:if test="$count < 2">
// runs when condition is true.
</xsl:if>
</xsl:if>
thanks in advance.
XSLT is a functional language and as such has immutable variables — once assigned their contents cannot be changed.
You need to stop thinking procedurally. Explain your problem and many people will show you how to solve this problem without incrementing any variable.
For example, the solution can be as simple as this:
On more complex situations, you may write a template that calls itself recursively, passing a specific parameter with value 1-greater than the value it has in the current template call.