title: XML and XSLT to write output to text file
body: <p>I am trying to use increment in XSLT. and write the output to txt file.
  Here's my code:
  Xslt code:</p>
  
  <pre><code>&lt;?xml version="1.0"?&gt;
  &lt;xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" &gt;
      &lt;xsl:output method="text"/&gt;
      &lt;xsl:result-document href="foo.txt" method=text /&gt;
      &lt;xsl:template match="/"&gt;
      &lt;/xsl:template&gt;
  
    &lt;xsl:template match="/build/build"&gt;
      &lt;xsl:variable name="buildNumber" select="."/&gt;
      &lt;xsl:element name="build"&gt;
        &lt;xsl:value-of select="$buildNumber + 1"/&gt;
      &lt;/xsl:element&gt;
    &lt;/xsl:template&gt;
  
    &lt;xsl:template match="/|@*|node()"&gt;
      &lt;xsl:value-of select="build/major"/&gt;
      &lt;xsl:value-of select="build/minor"/&gt;
      &lt;xsl:value-of select="build/build"/&gt;
      &lt;xsl:value-of select="build/release"/&gt;
        &lt;xsl:copy&gt;
          &lt;xsl:apply-templates select="@*|node()"/&gt;
        &lt;/xsl:copy&gt;  
    &lt;/xsl:template&gt;
  &lt;/xsl:stylesheet&gt;
  </code></pre>
  
  <p>XML code is:</p>
  
  <pre><code> &lt;?xml version="1.0" encoding="utf-8"?&gt;
      &lt;?xml-stylesheet type="text/xsl" href="E:\Build\genVer.xsl"?&gt;
      &lt;build&gt;
          &lt;major&gt;1.&lt;/major&gt;&lt;minor&gt;0.&lt;/minor&gt;&lt;build&gt;0&lt;/build&gt;&lt;release&gt;.0&lt;/release&gt;
      &lt;/build&gt;
  </code></pre>
  
  <p>I tried using <code>&lt;xsl:result-document&gt;</code> it gives error saying <code>&lt;xsl:result-document&gt;</code> cannot be child of <code>&lt;xsl:stylesheet&gt;</code> or <code>&lt;xsl:template&gt;</code>. Thankyou</p>