xsl-list
[Top] [All Lists]

Building a table with for-each

2005-05-18 12:07:11
Please bear with me as I'm new to this. I had a perfect solution to my
problem but it was accidentally wiped out. I'm trying to build a table
using 'for-each'. I've built separate tables for each of the unique
nodes, i.e. Sales, Credits, etc. However the last table uses
<type>DayXX</type, where XX is a number 0 -11. For the life of me I
can't remember how I did my 'for-each' statement to build that table
with multiple rows. I've been searching through the archive as I'm
pretty sure I used an example from there but I can't find it. I'm pretty
sure my code was something like this but it just isn't cutting it:

</table>
  <table border="1" id="table5" width="100%">
     <tr bgcolor="#E1ECFC">
         <th>Date</th>
         <th>Orders</th>
    </tr>
  <xsl:for-each select="xTable/orders[type=(., 'Day')]">
     <tr>
         <td><xsl:value-of select="date"/></td>
         <td><xsl:value-of select="count"/></td>
    </tr>
   </xsl:for-each>
</table>



Here's my xml:

<xTable>
        <orders>
                <type>Sales</type>
                <count>486</count>
                <value>18</value>
        </orders>
        <orders>
                <type>Credits</type>
                <count>17</count>
                <value>169.11</value>
        </orders>
        <orders>
                <type>Coupons</type>
                <count>6</count>
                <value>100.00</value>
        </orders>
        <orders>
                <type>Replacements</type>
                <count>3</count>
                <value>0</value>
        </orders>
        <orders>
                <type>Day0</type>
                <count>1,894</count>
                <value/>
                <date>04/28</date>
        </orders>
        <orders>
                <type>Day1</type>
                <count>1,792</count>
                <value/>
                <date>04/29</date>
        </orders>
        <orders>
                <type>Day2</type>
                <count>30</count>
                <value/>
                <date>04/30</date>
        </orders>
        <orders>
                <type>Day3</type>
                <count>2,306</count>
                <value/>
                <date>05/02</date>
        </orders>
        <orders>
                <type>Day4</type>
                <count>2,086</count>
                <value/>
                <date>05/03</date>
        </orders>
        <orders>
                <type>Day5</type>
                <count>1,913</count>
                <value/>
                <date>05/04</date>
        </orders>
        <orders>
                <type>Day6</type>
                <count>1,896</count>
                <value/>
                <date>05/05</date>
        </orders>
        <orders>
                <type>Day7</type>
                <count>1,829</count>
                <value/>
                <date>05/06</date>
        </orders>
        <orders>
                <type>Day8</type>
                <count>39</count>
                <value/>
                <date>05/07</date>
        </orders>
        <orders>
                <type>Day9</type>
                <count>2,053</count>
                <value/>
                <date>05/09</date>
        </orders>
        <orders>
                <type>Day10</type>
                <count>486</count>
                <value/>
                <date>05/10</date>
        </orders>
        <orders>
                <type>Day11</type>
                <count>102</count>
                <value/>
                <date>05/11</date>
        </orders>
</xTable>

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--



<Prev in Thread] Current Thread [Next in Thread>