XSLT is a functional programming language and as such it is very different to any procedural languages you already know.
Although for
loops are possible in XSLT, they do not make use of the inherent strengths of XSLT (and functional programming in general).
for
loops are routinely misused to address problems that are best solved with a functional approach instead (that is, matching templates). In other words, a loop is not really a "classic" in XSLT.
So, you might have to double back, identify the problem you are facing instead of discussion your solution. Then, the XSLT community might be able to suggest a solution that is more functional in nature. It might be that you've fallen victim to the XY problem.
Now, among the things XSLT is inherently good at is recursion. Often, problems that are solved with loops in procedural languages are solved with recursive templates in XSLT.
<xsl:template name="recursive-template">
<xsl:param name="var" select="5"/>
<xsl:choose>
<xsl:when test="$var > 0">
<xsl:value-of select="$var"/>
<xsl:call-template name="recursive-template">
<xsl:with-param name="var" select="$var - 1"/>
</xsl:call-template>
</xsl:when>
<xsl:otherwise/>
</xsl:choose>
</xsl:template>
To summarize, I suggest you look at "classic" recursion instead of "classic" for
loops. You find more information about exactly this topic in an IBM article here.
EDIT as a response to your edited question. If your problem really boils down to outputting text content twice:
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="text"/>
<xsl:template match="/foo">
<xsl:apply-templates select="bar"/>
<xsl:apply-templates select="bar"/>
</xsl:template>
</xsl:stylesheet>
This is not feasible of course for a dynamic number of iterations.