Counter inside xsl:for-each loop

Counter inside xsl:for-each loop

Asked on January 4, 2019 in XML.
Add Comment


  • 3 Answer(s)

         The counter inside the xsl:for-each loop by position().

    For instance,

    <countNo><xsl:value-of select="position()" /></countNo>
    
    Answered on January 4, 2019.
    Add Comment

         This could be the alternative for counter inside the xsl for all loops. Try the below code,

    <xsl:number format="1. "/><xsl:value-of select="."/><xsl:text>
    

         The “1. ” – is the number format. For further info here

    Answered on January 4, 2019.
    Add Comment

    Make a try on the given code:

    <xsl:value-of select="count(preceding-sibling::*) + 1" />
    

         It has a brain freeze there, position() is more direct.

    Answered on January 4, 2019.
    Add Comment


  • Your Answer

    By posting your answer, you agree to the privacy policy and terms of service.