Thanks for your suggestions. I was able to solve the issue in a slightly different way, but your hints has been super useful!!!
Here the solution I designed (the XPaths are a bit more complex w.r.t the example and I also needed to perform a check on an attribute ^_^):
<xsl:template match="/">
<xsl:for-each select="a/b/c/d/e/f[attribute::name = 'blablabla']"><xsl:variable name="currNode" select="position()"/>
<xsl:variable name="uri" select="concat('multi_',$currNode,.xml')"/>
<xsl:result-document href="{$uri}"><xsl:apply-templates select="../../../../../../*">
<xsl:with-param name="counter" select="$currNode"/>
</xsl:apply-templates>
</xsl:result-document>
</xsl:for-each>
</xsl:template>
<xsl:template match="node( ) | @*">
<xsl:param name="counter"/>
<xsl:copy>
<xsl:apply-templates select="@* | node( )">
<xsl:with-param name="counter" select="$counter"/>
</xsl:apply-templates>
</xsl:copy>
</xsl:template>
<xsl:template match="d/e/f">
<xsl:param name="counter"/>
<xsl:choose><xsl:when test="self::node()[attribute::name = 'blablabla'] and position()=$counter*2"><NEW name="NEW"/></xsl:when>
<xsl:otherwise><xsl:copy>
<xsl:apply-templates select="@* | node( )">
<xsl:with-param name="counter" select="$counter"/>
</xsl:apply-templates>
</xsl:copy>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
The use of <xsl:apply-templates select="../../../../../../*"> was necessary in order to get the whole original file copied, otherwise, only the changed part of the tree were displayed in the result files. I know that probably there are better solutions (with a cleaner and simplier style) but this seems to work and for now I'll keep it :D
Another question: Do you know why I had to use
"position()=$counter*2"? By using only position()=$counter when $counter was equal 1 no changes occurred, and when it was equal 2 only the first occurrence of <f name='blablabla'> where changed.
Thanks again for your help!!!
Axon