title: XSLT for loop or alternative for node duplication
body: <p>In my reading, it's become quite obvious that the only sane workaround to <code>for i .. m</code> loops in XSLT 1.0 is using a recursive template.</p>
  
  <p>Unless someone can explain otherwise, it further seems that given the constraints of XSLT processing, this approach isn't generically reusable.</p>
  
  <p>Anyway, given an input snippet (<em>the context node in this case</em>) of:</p>
  
  <pre><code>&lt;items count="3"&gt;
      &lt;item&gt;
          &lt;name&gt;Name&lt;/name&gt;
          &lt;description&gt;Description&lt;/description&gt;
      &lt;/item&gt;
  &lt;/items&gt;
  </code></pre>
  
  <p>Is there a reusable strategy to duplicate the <code>&lt;item&gt;</code> child based on the <code>count</code> attribute? The expected output here would simply be</p>
  
  <pre><code>&lt;item&gt;
      &lt;name&gt;Name&lt;/name&gt;
      &lt;description&gt;Description&lt;/description&gt;
  &lt;/item&gt;
  &lt;item&gt;
      &lt;name&gt;Name&lt;/name&gt;
      &lt;description&gt;Description&lt;/description&gt;
  &lt;/item&gt;
  &lt;item&gt;
      &lt;name&gt;Name&lt;/name&gt;
      &lt;description&gt;Description&lt;/description&gt;
  &lt;/item&gt;
  </code></pre>
  
  <p>I intend to perform further transformations on the <code>&lt;item&gt;</code> nodes, however I don't think they're relevant.</p>
  
  <p>Reusability is a point of concern for me, for the simple reason that the <code>count</code> attribute is quite common among elements of the input documents, and the semantic intent is just as described by my example above.</p>
  
  <p>If I were to use the recursive-iterator approach, I'd have to bake that into every template (<em>which would be very not DRY; more like very WET, as in "why even try"; but I digress</em>)</p>
  
  <p>If there <em>is</em> a strategy to creating a generic <code>for</code> template, with which any transformation operations can be performed, that would be just spectacular. If I can get away without using any recursive-iterators, if some gem of a function for this purpose is tucked away in XSLT 1.0, that would be equally spectacular.</p>
  
  <p>Anyway, how can I accomplish this? Do I need to resort to the WET approach, or is there a better way?</p>