Hi All,

I have some elements which have some attributes. I'm using the following key to obtain the correct set of elements to sort and total against.

<xsl:key name="giveSum" match="PSL_PREMIUMS_V[@UNIT_NBR &gt; 0]" use="@POLICY_ID"/>

<xsl:variable name="getTotals" select="key('giveSum', @POLICY_ID)"/>

with my test data getTotals holds 3 elements which is what i'd expect.

They all have an attribute called COVERAGE_CD which I want to sort against then I want to total on an attribute called PLP_PREMIUM_AMT. I expect to get 2 lines output, but following the examples in michael kay's book p275-276 using sum doesn't seem to give me the results and I still get three seperate lines. I figured this was because it's in a for-each loop so I thought I'd do the sort and an apply templates, but I keep being told I cannot use sort in the place specified. Can anyone give me any pointers as to how I should be sorting and totaling based on the values obtained by my key.

So if my three lines in getTotals are:

<PSL_PREMIUMS_V COVERAGE_CD="QAS" PLP_PREMIUM_AMT="10.00" ......
<PSL_PREMIUMS_V COVERAGE_CD="APL" PLP_PREMIUM_AMT="10.00" ......
<PSL_PREMIUMS_V COVERAGE_CD="QAS" PLP_PREMIUM_AMT="12.00" ......

I want to end up with
<TOTAL COVERAGE_CD="QAS" VALUE="22.00">
<TOTAL COVERAGE_CD="APL" VALUE="10.00">

I know that if I use :
<xsl:sort select="@COVERAGE_CD"/>
this will group the details correctly.

Regards
Bill Crawley