
June 1st, 2001, 07:07 AM
|
 |
Madden Maniac
|
|
Join Date: Jun 2001
Location: Finland
Posts: 519
 
Time spent in forums: 1 Day 3 h 47 m 50 sec
Reputation Power: 12
|
|
|
creating a table
I have the following kind of XML-file that I wish to convert to HTML table:
<DATASET>
<TIMESTAMP>1.6.2001 14:22:11</TIMESTAMP>
<ROW>
<PRODUCT_NAME>DeLuxeBar</PRODUCT_NAME>
<MACHINE_ID>123456</MACHINE_ID>
<SALE_TIME>2001-06-01 14:22:05</SALE_TIME>
<SALE_COUNT>1</SALE_COUNT>
<SALE_PRICE>55</SALE_PRICE>
<_SALE_COUNTxSALE_PRICE_>55</_SALE_COUNTxSALE_PRICE_>
</ROW>
<ROW>
<PRODUCT_NAME>Diet Snack</PRODUCT_NAME>
<MACHINE_ID>123456</MACHINE_ID>
<SALE_TIME>2001-06-01 14:22:05</SALE_TIME>
<SALE_COUNT>1</SALE_COUNT>
<SALE_PRICE>10</SALE_PRICE>
<_SALE_COUNTxSALE_PRICE_>10</_SALE_COUNTxSALE_PRICE_>
</ROW>
my XSL-file considering the table is following:
<TR>
<TH>Machine</TH>
<TH>Sale Count</TH>
<TH>Sale</TH>
<TH>Average Sale</TH>
</TR>
<TR>
<TD align="center"><xsl:value-of select="DATASET/ROW/MACHINE_ID"/></TD>
<TD align="center"><xsl:value-of select="sum(DATASET/ROW/SALE_COUNT)"/></TD>
<TD align="center"><xsl:value-of select="sum(DATASET/ROW[MACHINE_ID=123456]/_SALE_COUNTxSALE_PRICE_)"/></TD>
<xsl:variable name='ekaaverage' select="sum(DATASET/ROW[MACHINE_ID=123456]/_SALE_COUNTxSALE_PRICE_) div sum(DATASET/ROW[MACHINE_ID=123456]/SALE_COUNT)"/>
<TD align="center"><xsl:value-of select='format-number($ekaaverage, "##0.00")'/></TD>
</TR>
<TR>
<TD align="center"><xsl:value-of select="DATASET/ROW[MACHINE_ID=234567]/AUT_ID"/></TD>
<TD align="center"><xsl:value-of select="sum(DATASET/ROW[MACHINE_ID=234567]/SALE_COUNT)"/></TD>
<TD align="center"><xsl:value-of select="sum(DATASET/ROW[MACHINE_ID=234567]/_SALE_COUNTxSALE_PRICE_)"/></TD>
<xsl:variable name='tokaaverage' select="sum(DATASET/ROW[MACHINE_ID=234567]/_SALE_COUNTxSALE_PRICE_) div sum(DATASET/ROW[MACHINE_ID=234567]/SALE_COUNT)"/>
<TD align="center"><xsl:value-of select='format-number($tokaaverage, "##0.00")'/></TD>
</TR>
<TR>
So I finally get to the question... My XML data has MACHINE_ID:s that can be any number.XML-file is also growing all the time as the XML-file is created from a database. And I wish to create a table in html so that the data is sorted by MACHINE_ID. The HTML-table can have any amount of rows depending on how many different MACHINE_ID:s there are.And that's giving me a hard time...(2 days). Could I use <xsl:for-each> somehow??? Or is there a alternative method?
|