#1
  1. Madden Maniac
    Devshed Novice (500 - 999 posts)

    Join Date
    Jun 2001
    Location
    Finland
    Posts
    519
    Rep Power
    14

    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?
  2. #2
  3. Madden Maniac
    Devshed Novice (500 - 999 posts)

    Join Date
    Jun 2001
    Location
    Finland
    Posts
    519
    Rep Power
    14

    Talking Actually it was quite easy...


    the answer was actually so simple. Just a bit diiferent SQL query and then it worked with for-each... Finally a word of advise enjoy your summer!!! I know I will...

IMN logo majestic logo threadwatch logo seochat tools logo