Your approach <xsl:result-document>sounds great. The only problem is that your stylesheet is XSLT 1, but <xsl:result-document>you need XSLT 2. XSLT, which is a functional language, has nothing to do with this problem.
Post your XSLT code that uses <xsl:result-document>, if necessary , and I will fix it for you.
Edit:
. , method="text", , , <xsl:element> , XML , . , <xsl:result-document> XSLT 2.
XML:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml"/>
<xsl:template match="/">
<xsl:variable name="foldername" select="concat(/build/major, /build/minor, string(/build/build + 1), build/release)"/>
<xsl:result-document href="{$foldername}/foo.xml" method="xml">
<xsl:copy>
<xsl:apply-templates/>
</xsl:copy>
</xsl:result-document>
</xsl:template>
<xsl:template match="element()">
<xsl:copy>
<xsl:apply-templates/>
</xsl:copy>
</xsl:template>
<xsl:template match="/build/build">
<xsl:copy>
<xsl:variable name="buildNumber" select="."/>
<xsl:value-of select="$buildNumber + 1"/>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="text"/>
<xsl:template match="/">
<xsl:variable name="foldername" select="concat(/build/major, /build/minor, string(/build/build + 1), build/release)"/>
<xsl:result-document href="{$foldername}/foo.txt" method="text">
<xsl:apply-templates/>
</xsl:result-document>
</xsl:template>
<xsl:template match="element()">
<xsl:apply-templates/>
</xsl:template>
<xsl:template match="/build/build">
<xsl:variable name="buildNumber" select="."/>
<xsl:value-of select="$buildNumber + 1"/>
</xsl:template>
</xsl:stylesheet>
, , , , .