title: XSLT Expand input XML using a for-loop type operation
body: <p>I'm new to XSLT, forgive my ignorance, if I have input XML like this:</p>
  
  <pre><code>&lt;Doc&gt;
   &lt;stuff&gt;
     &lt;for var="i" from="1" to="2"&gt;
        &lt;item&gt;$(i)&gt;&lt;/item&gt;
        &lt;for var="j" from="2" to="4"&gt;
          &lt;innerItem&gt;$(j)&lt;/innerItem&gt;
        &lt;/for&gt;
      &lt;/for&gt;    
    &lt;/stuff&gt;
  &lt;/Doc&gt;
  </code></pre>
  
  <p>I want to use a transform to have the output XML expanded like this:</p>
  
  <pre><code>&lt;Doc&gt;
   &lt;stuff&gt;
     &lt;item&gt;1&lt;/item&gt;
       &lt;innerItem&gt;2&lt;/innerItem&gt;
       &lt;innerItem&gt;3&lt;/innerItem&gt;
       &lt;innerItem&gt;4&lt;/innerItem&gt;
     &lt;item&gt;2&lt;/item&gt;
       &lt;innerItem&gt;2&lt;/innerItem&gt;
       &lt;innerItem&gt;3&lt;/innerItem&gt;
       &lt;innerItem&gt;4&lt;/innerItem&gt;
   &lt;/stuff&gt;
  &lt;/Doc&gt;
  </code></pre>
  
  <p>All I've got is this: what to do next?</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
      xmlns:msxsl="urn:schemas-microsoft-com:xslt" exclude-result-prefixes="msxsl"
  &gt;
      &lt;xsl:output method="xml" indent="yes"/&gt;
  
      &lt;xsl:template match="@* | node()"&gt;
          &lt;xsl:copy&gt;         
              &lt;xsl:apply-templates select="@* | node()"/&gt;
          &lt;/xsl:copy&gt;
      &lt;/xsl:template&gt;
  
    &lt;xsl:template match="for"&gt;
      &lt;xsl:variable name="from" select="@from" /&gt;
      &lt;xsl:variable name="to" select="@to" /&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>