title: Iteration, or copying in XSL, based on a count. How do I do it?
body: <p>I'm trying to create an inventory list (tab-delimited text, for the output) from XML data.  The catch is, I need to take the line that I created, and list it multiple times (iterate ???), based on a number found in the XML.  So, from the XML below:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;library&gt;
    &lt;aisle label="AA"&gt;
      &lt;row&gt;bb&lt;/row&gt;
      &lt;shelf&gt;a&lt;/shelf&gt;
      &lt;books&gt;4&lt;/books&gt;
    &lt;/aisle&gt;
    &lt;aisle label="BB"&gt;
      &lt;row&gt;cc&lt;/row&gt;
      &lt;shelf&gt;d&lt;/shelf&gt;
      &lt;books&gt;3&lt;/books&gt;
    &lt;/aisle&gt;
  &lt;/library&gt;
  </code></pre>
  
  <p>I need to take the value found in "books", and then copy the text line that number of times.  The result looking like this:</p>
  
  <pre><code>Aisle   Row Shelf   Titles
  AA     bb   a   
  AA     bb   a   
  AA     bb   a   
  AA     bb   a   
  BB     cc   d   
  BB     cc   d   
  BB     cc   d   
  </code></pre>
  
  <p>So that the inventory taker, can then write in the titles found on each shelf.  I have the basic structure of my XSL, but I'm not sure how to do the "iteration" portion.</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  xmlns:xs="http://www.w3.org/2001/XMLSchema" exclude-result-prefixes="xs"
  xmlns:xd="http://www.oxygenxml.com/ns/doc/xsl" version="2.0"&gt;
  
  &lt;xsl:output omit-xml-declaration="yes"/&gt;
  &lt;xsl:variable name="tab" select="'&amp;#09;'"/&gt;
  &lt;xsl:variable name="newline" select="'&amp;#10;'"/&gt;
  
  &lt;xsl:template match="/"&gt;
      &lt;!-- Start Spreadsheet header --&gt;
      &lt;xsl:text&gt;Aisle&lt;/xsl:text&gt;
      &lt;xsl:value-of select="$tab"/&gt;
      &lt;xsl:text&gt;Row&lt;/xsl:text&gt;
      &lt;xsl:value-of select="$tab"/&gt;
      &lt;xsl:text&gt;Shelf&lt;/xsl:text&gt;
      &lt;xsl:value-of select="$tab"/&gt;
      &lt;xsl:text&gt;Titles&lt;/xsl:text&gt;
      &lt;xsl:value-of select="$newline"/&gt;
      &lt;!-- End spreadsheet header --&gt;
  
      &lt;!-- Start entering values from XML --&gt;
      &lt;xsl:for-each select="library/aisle"&gt;
          &lt;xsl:value-of select="@label"/&gt;
          &lt;xsl:value-of select="$tab"/&gt;
          &lt;xsl:value-of select="row"/&gt;
          &lt;xsl:value-of select="$tab"/&gt;
          &lt;xsl:value-of select="shelf"/&gt;
          &lt;xsl:value-of select="$tab"/&gt;
          &lt;xsl:value-of select="$tab"/&gt;
          &lt;xsl:value-of select="$newline"/&gt;
      &lt;/xsl:for-each&gt;
      &lt;!-- End of values from XML --&gt;
  
      &lt;!-- Iteration of the above needed, based on count value in "books" --&gt;
  
  &lt;/xsl:template&gt;
  &lt;/xsl:stylesheet&gt;
  </code></pre>
  
  <p>Any help would be greatly appreciated.  For starters, is "iteration" the right term to be using for this?</p>
  
  <p>Thanks!</p>