xslt - xsl : Incrementing a global variable -


i know fact variables in xsl immutable. in scenario, want increment global variable , use value later. there other way can done? have added enough comments in code make question more clear. please note using xslt 1.0

<xsl:variable name="counter">0</xsl:variable> <xsl:template match="/">  <xsl:for-each select="condition_abc">   <xsl:variable name="returnvalue"> <!--returnvalue return value named template getvalue -->    <xsl:call-template name="getvalue"/>   </xsl:variable>   <xsl:if test="not($returnvalue= '')">    <!-- if returned value not null         here want add increment logic,          $counter = $counter+ 1  -->    <xsl:value-of select="."/>   </xsl:if>  </xsl:for-each> </xsl:template>  <xsl:template match="some_pattern">  <attribute>   <!-- final 'counter' value above xsl block needs outputted here -->   <xsl:value-of select="$counter"/>  </attribute> </xsl:template> 


Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

CSS3 Transition to highlight new elements created in JQuery -