GavinP1983
Programmer
I didn't really explain my problem well in the previous post so I thought I'd try again.
My stylesheet is:
My XML is:
It's not the best, but I'm new so please bear with me. Basically, the Stylesheet reads in the customer data from the XML file but I can't get it to arrange properly.
I'd like to arrange everyone by store. For example, I'd like everyone who visited the store in 'Yoevil' to be in the same table. I've done this a crude way - I've actually specified the store name as you'll see. This works, but it's not brilliant because the store could change at any time (<store>Yeovil</store>). I know I need some sort of loop or XPath but I'm having trouble getting my head round it!
Secondly, I'm able to display the total value of the <value> fields, which is great but I need a sub total for each store. I've tried variables and incrementing them as <value> is iterated but I still can't get that to work either!
The final thing should be something like:
Store: Yeovil
Customer Name | Details | Value
Sub total: (value)
Store: Next Store
Customer Name | Details | Value
Sub total: (value)
Grand total: (value + value)
Any help much appreciated!
My stylesheet is:
Code:
<?xml version="1.0" encoding="ISO-8859-1"?><xsl:stylesheet version="1.0"
xmlns:xsl="[URL unfurl="true"]http://www.w3.org/1999/XSL/Transform"><xsl:template[/URL] match="/">
<html>
<body>
<xsl:variable name="runningtotal">0</xsl:variable>
<hr />
<h1>List of Individual Stores:</h1>
<h2>Yeovil:</h2>
<table border="1" width="100%" id="table1">
<tr>
<td><b>Sender</b></td>
<td><b>Customer</b></td>
<td><b>Address</b></td>
<td><b>Gift</b></td>
<td><b>Value</b></td>
</tr>
<xsl:for-each select="NewDataSet/Table[Store='Yeovil']">
<xsl:sort select="Store"/>
<tr>
<td><xsl:value-of select="Sender"/></td>
<td><xsl:value-of select="Customer"/></td>
<td><xsl:value-of select="Address"/></td>
<td><xsl:value-of select="Gift"/></td>
<td>£<xsl:value-of select="sum(Value)"/></td>
<td></td>
</tr>
<p />
</xsl:for-each>
<td>Running total:
// only want the total for yeovil, not everything
<xsl:value-of select="sum(NewDataSet/Table/Value)" />
</td>
<tr><td></td><td></td><td></td><td></td><td>
<b>
</b>
</td></tr>
</table>
<h1>Grand Total</h1>£<xsl:value-of select="sum(NewDataSet/Table/Value)" />
<hr />
</body>
</html>
</xsl:template></xsl:stylesheet>
My XML is:
Code:
<?xml version='1.0'?>
<?xml-stylesheet type="text/xsl" href="stylesheet.xsl"?>
<NewDataSet><Table><Year>2005</Year><Month>6</Month><Store>Bath</Store><Reason>Repair Issue</Reason><Sender>Ms Margaret Roberts</Sender><Customer>Miss Narissa Fish</Customer><Address>48 Warminster Road,
Westbury
Wilts
BA13 3PF</Address><Gift>O1008 - Starlight Bouquet</Gift><Value>31.4700</Value></Table><Table><Year>2005</Year><Month>6</Month><Store>Bluewater</Store><Reason>Customer Service</Reason><Sender>Ms Gina Bonner</Sender><Customer>Mrs Marshall</Customer><Address>the pines
35 rowanwood avenue
the hollies
sidcup da158wl</Address><Gift>O7309 - Semillon Chardonnay - Sacred Hill</Gift><Value>14.4900</Value></Table><Table><Year>2005</Year><Month>6</Month><Store>Bluewater</Store><Reason>Billing Issue</Reason><Sender>Ms Gina Bonner</Sender><Customer>Mr David HALLS</Customer><Address>4, HOWELLS CLOSE
WEST KINGSDOWN
SEVENOAKS
KENT TN15 6EE</Address><Gift>O7309 - Semillon Chardonnay - Sacred Hill</Gift><Value>14.4900</Value></Table>...</NewDataSet>
It's not the best, but I'm new so please bear with me. Basically, the Stylesheet reads in the customer data from the XML file but I can't get it to arrange properly.
I'd like to arrange everyone by store. For example, I'd like everyone who visited the store in 'Yoevil' to be in the same table. I've done this a crude way - I've actually specified the store name as you'll see. This works, but it's not brilliant because the store could change at any time (<store>Yeovil</store>). I know I need some sort of loop or XPath but I'm having trouble getting my head round it!
Secondly, I'm able to display the total value of the <value> fields, which is great but I need a sub total for each store. I've tried variables and incrementing them as <value> is iterated but I still can't get that to work either!
The final thing should be something like:
Store: Yeovil
Customer Name | Details | Value
Sub total: (value)
Store: Next Store
Customer Name | Details | Value
Sub total: (value)
Grand total: (value + value)
Any help much appreciated!