Subject:Adding the content of an element and displaying the total Author:Scott Reed Date:27 Jan 2008 11:43 AM
Code examples below...
I have a customer who has a jBidWatcher auctions.xml with about four years of auction information stored within. I put together a little xsl stylesheet to extract the information from the auctions.xml and present the info in a more readable format. He likes what I have put together so far, but would like a summary at the bottom of the page which shows totals.
What I want to do is create a loop that:
1 - Checks for the highbidder to be equal to w9evt1
2 - If highbidder equal to w9evt1 then grab value of currently price element
3 - loop again and keep adding together value of currently price until we have added all the possible prices on all the auctions that w9evt1 won.
4 - Display the output
<xsl:template match="/">
<html>
<body>
<h2>Archived Auction List</h2>
<table border="1">
<tr bgcolor="#9acd32">
<th align="left">ID</th>
<th align="left">Title</th>
<th align="left">Winner</th>
<th align="left">Price</th>
<th align="left">Ship</th>
</tr>
<xsl:for-each select="jbidwatcher/auctions/server/auction">
<xsl:sort select="@id"/>
<tr>
<!-- @id will allow us to display the id# from the auction tag -->
<td><xsl:value-of select="@id"/></td>
<td><xsl:value-of select="info/title"/></td>
<!-- Lets choose to highlight George's userid pink on all won auctions -->
<xsl:choose>
<!-- Note that w9evt is enclosed with '' -->
<xsl:when test="info/highbidder='w9evt1'">
<td bgcolor="#ff00ff">
<xsl:value-of select="info/highbidder"/></td>
</xsl:when>
<!-- If George was not the winner, than just display normal -->
<xsl:otherwise>
<td><xsl:value-of select="info/highbidder"/></td>
</xsl:otherwise>
</xsl:choose>
</table>
</body>
</html>
</xsl:template>
Subject:Adding the content of an element and displaying the total Author:Scott Reed Date:27 Jan 2008 09:12 PM
Well, looks like I figured out a method to do this... problem is, it requires the exslt common extension... which does not work nicely with firefox 2.x.
Firefox 3 beta 2 seems to work fine with the exsl extensions, but my customer does not have that and my webhost is on unix and I am not sure how do server side xml translation with php. Anyone have a better solution for me?