Use a Counter Inside a For-Each Loop to Track the Number of Loop Iterations
You can use a counter inside a for-each loop to track the number of
        iterations processed by the loop. This task can be achieved with an
            xsl:variable through direct edit of the XSLT code.
               
For example:
- Use the count()andposition()XPath functions.- The count(location path to the element)returns the number of instances for the node-set (for the element).
- Within an <xsl:for-each>loop, theposition()function returns the iteration number.
 
- The 
- The XSL code snippet for the payload looks as follows: 
- The pseudo XSL code snippet looks as follows: 
- The output looks as follows:

