I have final got what I want... and learnt a hell of a lot in the
process...
A combination of syntax and typos held me back some what... but I crawled
forward ...
Although looking that the other postings it is clear that I am way out of
my league. But I still thought it was worth posting the end result....
Thanks to Wendel and Mukul for the help...
XSL IS....
<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:key name="cards" match="ITEM" use="CARD/@number" />
<xsl:template match="/">
<xsl:for-each select="/ITEMS" >
<xsl:call-template name="create-body" />
</xsl:for-each>
</xsl:template>
<xsl:template name="create-body" >
<xsl:for-each select="./ITEM[CARD/@number and
generate-id(.) = generate-id(key('cards', CARD/@number))]" >
<BR/> VALUES FOR CARD: <xsl:value-of select
="CARD/@number"/>
<BR/> NUMBER OF ITEMS: <xsl:value-of select="count(key
('cards', CARD/@number))" />
<xsl:for-each select="key('cards', CARD/@number)" >
<BR/> Values <xsl:value-of select="AMOUNT/@amt" />
</xsl:for-each>
<BR/> TOTAL: <xsl:value-of select=" sum( key('cards',
CARD/@number)/AMOUNT/@amt ) "/>
<BR/>
</xsl:for-each>
<BR/> GRAND TOTAL: <xsl:value-of select="sum(//AMOUNT/@amt)" />
</xsl:template>
</xsl:stylesheet>
AND THE XML IS...
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="test.xsl"?>
<ITEMS>
<ITEM item_id='1'> <CARD number='123456789' amt='1'/> <AMOUNT amt
='100'/> </ITEM>
<ITEM item_id='2'> <CARD number='123456789' amt='2'/> <AMOUNT amt
='200'/> </ITEM>
<ITEM item_id='3'> <CARD number='987654321' amt='3'/> <AMOUNT amt
='30'/> </ITEM>
<ITEM item_id='4'> <CARD number='123456789' amt='4'/> <AMOUNT amt
='50'/> </ITEM>
<ITEM item_id='5'> <CARD number='987654321' amt='5'/> <AMOUNT amt
='150'/> </ITEM>
<ITEM item_id='6'> <CARD number='123456789' amt='6'/> <AMOUNT amt
='250'/> </ITEM>
</ITEMS>
WHICH GIVES ME THIS....
VALUES FOR CARD: 123456789
NUMBER OF ITEMS: 4
Values 100
Values 200
Values 50
Values 250
TOTAL: 600
VALUES FOR CARD: 987654321
NUMBER OF ITEMS: 2
Values 30
Values 150
TOTAL: 180
GRAND TOTAL: 780
***************************************
Roger Wyatt
Principal Consultant
Nomad Software Ltd.
***************************************
This e-mail (including attachments) is confidential and is intended solely
for the addressee. Unless authorised you may not read, copy, use or store
this e-mail in any way, or permit others to do so. If you have received it
in error, please contact Nomad Software on +44 (0) 20 7292 2400