[xsl] Re: Spam:[xsl] Building a table with for-each

Subject: [xsl] Re: Spam:[xsl] Building a table with for-each
From: JBryant@xxxxxxxxx
Date: Wed, 18 May 2005 14:15:20 -0500
Hi, Matt,

Sorry to hear about your mishap. From the looks of it, you need to use the 
contains() function.

<xsl:for-each select="xTable/orders[contains(type, 'Day')]">

will pick up just the orders whose type elements contain "Day".

HTH (and lemme know if not)

Jay Bryant
Bryant Communication Services
(presently consulting at Synergistic Solution Technologies)




"Selchow, Matt" <Matt.Selchow@xxxxxxxxxxxxxxxxx> 
05/18/2005 02:07 PM
Please respond to
xsl-list@xxxxxxxxxxxxxxxxxxxxxx


To
<xsl-list@xxxxxxxxxxxxxxxxxxxxxx>
cc

Subject
Spam:[xsl] Building a table with for-each






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>

Current Thread