XML Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming Languages - MoreXML Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old June 1st, 2001, 07:07 AM
Miska's Avatar
Miska Miska is offline
Madden Maniac
Dev Shed Novice (500 - 999 posts)
 
Join Date: Jun 2001
Location: Finland
Posts: 519 Miska User rank is Lance Corporal (50 - 100 Reputation Level)Miska User rank is Lance Corporal (50 - 100 Reputation Level)Miska User rank is Lance Corporal (50 - 100 Reputation Level) 
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?

Reply With Quote
  #2  
Old June 5th, 2001, 01:17 AM
Miska's Avatar
Miska Miska is offline
Madden Maniac
Dev Shed Novice (500 - 999 posts)
 
Join Date: Jun 2001
Location: Finland
Posts: 519 Miska User rank is Lance Corporal (50 - 100 Reputation Level)Miska User rank is Lance Corporal (50 - 100 Reputation Level)Miska User rank is Lance Corporal (50 - 100 Reputation Level) 
Time spent in forums: 1 Day 3 h 47 m 50 sec
Reputation Power: 12
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...

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreXML Programming > creating a table

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap