[xsl] XSL: Build a dynamic HTML Select from a single Quantity value

Subject: [xsl] XSL: Build a dynamic HTML Select from a single Quantity value
From: Jimmy D <webnet02@xxxxxxxxx>
Date: Thu, 7 Aug 2008 08:56:23 -0700 (PDT)
Hi,
 
I've searched the web and archives for the specifics on this process but
haven't found a good match for what I am trying to accomplish.  
 
I have the
following XML from a third party source I pull from the web to populate a web
page on my site:
 
<?xml version="1.0" encoding="utf-8" ?>
<Products>
       <Data Count="2">
           <Item>
               <Product>Widget
1</Product>
               <Quantity>3</Quantity>
              
<Price>10</Price>
           </Item>
           <Item> 
              
<Product>Widget 2</Product>
               <Quantity>2</Quantity>
               <Price>15</Price>
           </Item>
       </Data>
</Products>
 
In my style sheet I need to build a HTML drop-down with sequential option
values equal to the number in <Quantity> like so..  
Widget 1
<select
name="Quantity">
    <option value="1">1</option>
    <option
value="2">2</option>
    <option value="3">3</option>
</select>
 
Widget 2
<select name="Quantity">
    <option value="1">1</option>
    <option
value="2">2</option>
</select>
I am somewhat new to writing style sheets but I
am experienced in ASP / VBscript where I would handle this with a For / Next
like:
<select name="Quantity">
   <% For count = 1 to Quantity
            response.write("<option value='" & count & "'>" & count &
"</option>")
         Next %>                                   
</select>
 
However, I haven't figured out how to do this in my style sheet.  My XSL looks
something like this at the moment:
 
<?xml version="1.0"
encoding="ISO-8859-1"?>
<xsl:stylesheet version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>
 <xsl:template match="/">
   <xsl:choose>
    <xsl:when test="Products/Data/Item">
        <table>
   
    <xsl:for-each select="Products/Data/Item">
            <tr>
           
    <td>
                <xsl:value-of select="Product" />
               
</td>
                <td>
                <xsl:value-of select="Price" />
   
            </td>
                <td>Select the number you want to order: 
                    <select name="Quantity">
                        <!--
Where I'm Stuck -->
                    </select>
                </td>
              </tr>
        </xsl:for-each>
        </table>
    </xsl:when>
    <xsl:otherwise>
    </xsl:otherwise>
   </xsl:choose>
 </xsl:template>
</xsl:stylesheet>
Thanks for your assistance!
Jim

Current Thread