XSLT expert required..thanks.
I am generating subtotals and it works fine..however it does not generate them or generated improperly if I filter in the apply-template like <xsl:apply-templates select="MyTable[curr_code='AUD']" >. If I just code <xsl:apply-templates select="MyTable"/> it works.
The XML is :
<MyDataSet>
<MyTable>
<bs_group>Assets</bs_group>
<bs_categ>01. Cash & Due from Banks</bs_categ>
<curr_code>AUD</curr_code>
<ps_download>487637.750</ps_download>
</MyTable>
<MyTable>
<bs_group>Assets</bs_group>
<bs_categ>01. Cash & Due from Banks</bs_categ>
<curr_code>AUD</curr_code>
<ps_download>-587788.493</ps_download>
</MyTable>
<MyTable>
<bs_group>Assets</bs_group>
<bs_categ>01. Cash & Due from Banks</bs_categ>
<curr_code>CAD</curr_code>
<ps_download>73108.752</ps_download>
</MyTable>
<MyTable>
<bs_group>Assets</bs_group>
<bs_categ>01. Cash & Due from Banks</bs_categ>
<curr_code>GBP</curr_code>
<ps_download>4262274.160</ps_download>
</MyTable>
<MyTable>
<bs_group>Assets</bs_group>
<bs_categ>01. Cash & Due from Banks</bs_categ>
<curr_code>GBP</curr_code>
<ps_download>-2956402.499</ps_download>
</MyTable>
<MyTable>
<bs_group>Assets</bs_group>
<bs_categ>01. Cash & Due from Banks</bs_categ>
<curr_code>USD</curr_code>
<ps_download>10514518.380</ps_download>
</MyTable>
<MyTable>
<bs_group>Assets</bs_group>
<bs_categ>02.Securities</bs_categ>
<curr_code>USD</curr_code>
<ps_download>18294190.340</ps_download>
</MyTable>
<MyTable>
<bs_group>Assets</bs_group>
<bs_categ>02.Securities</bs_categ>
<curr_code>USD</curr_code>
<ps_download>-18206224.390</ps_download>
</MyTable>
<MyTable>
<bs_group>Assets</bs_group>
<bs_categ>04.Loans</bs_categ>
<curr_code>AUD</curr_code>
<ps_download>93587.020</ps_download>
</MyTable>
<MyTable>
<bs_group>Assets</bs_group>
<bs_categ>04.Loans</bs_categ>
<curr_code>AUD</curr_code>
<ps_download>5802.950</ps_download>
</MyTable>
<MyTable>
<bs_group>Assets</bs_group>
<bs_categ>04.Loans</bs_categ>
<curr_code>USD</curr_code>
<ps_download>-742934.750</ps_download>
</MyTable>
<MyTable>
<bs_group>Assets</bs_group>
<bs_categ>04.Loans</bs_categ>
<curr_code>USD</curr_code>
<ps_download>-15000000.000</ps_download>
</MyTable>
<MyTable>
<bs_group>Assets</bs_group>
<bs_categ>05.Trading Assets</bs_categ>
<curr_code>USD</curr_code>
<ps_download>17878.430</ps_download>
</MyTable>
<MyTable>
<bs_group>Assets</bs_group>
<bs_categ>05.Trading Assets</bs_categ>
<curr_code>USD</curr_code>
<ps_download>11952104.300</ps_download>
</MyTable>
<MyTable>
<bs_group>Assets</bs_group>
<bs_categ>05.Trading Assets</bs_categ>
<curr_code>USD</curr_code>
<ps_download>53801336.000</ps_download>
</MyTable>
<MyTable>
<bs_group>Assets</bs_group>
<bs_categ>05.Trading Assets</bs_categ>
<curr_code>USD</curr_code>
<ps_download>450000000.000</ps_download>
</MyTable>
<MyTable>
<bs_group>Assets</bs_group>
<bs_categ>06.Other Assets</bs_categ>
<curr_code>USD</curr_code>
<ps_download>-4786154.220</ps_download>
</MyTable>
<MyTable>
<bs_group>Assets</bs_group>
<bs_categ>06.Other Assets</bs_categ>
<curr_code>USD</curr_code>
<ps_download>-6098133.630</ps_download>
</MyTable>
<MyTable>
<bs_group>Assets</bs_group>
<bs_categ>06.Other Assets</bs_categ>
<curr_code>USD</curr_code>
<ps_download>-6976731.810</ps_download>
</MyTable>
<MyTable>
<bs_group>Assets</bs_group>
<bs_categ>06.Other Assets</bs_categ>
<curr_code>USD</curr_code>
<ps_download>-8804476.850</ps_download>
</MyTable>
<MyTable>
<bs_group>Assets</bs_group>
<bs_categ>07.Due To/From Related Parties</bs_categ>
<curr_code>USD</curr_code>
<ps_download>-188018136.380</ps_download>
</MyTable>
<MyTable>
<bs_group>Assets</bs_group>
<bs_categ>07.Due To/From Related Parties</bs_categ>
<curr_code>USD</curr_code>
<ps_download>-195306355.530</ps_download>
</MyTable>
<MyTable>
<bs_group>Assets</bs_group>
<bs_categ>07.Due To/From Related Parties</bs_categ>
<curr_code>USD</curr_code>
<ps_download>-2635857513.620</ps_download>
</MyTable>
<MyTable>
<bs_group>Assets</bs_group>
<bs_categ>07.Due To/From Related Parties</bs_categ>
<curr_code>USD</curr_code>
<ps_download>-36672230504.810</ps_download>
</MyTable>
<MyTable>
<bs_group>Liabilities</bs_group>
<bs_categ>08.Deposits</bs_categ>
<curr_code>USD</curr_code>
<ps_download>-340000000.000</ps_download>
</MyTable>
<MyTable>\r\n
<bs_group>Liabilities</bs_group>
<bs_categ>08.Deposits</bs_categ>
<curr_code>USD</curr_code>
<ps_download>-350000000.000</ps_download>
</MyTable>
<MyTable>
<bs_group>Liabilities</bs_group>
<bs_categ>08.Deposits</bs_categ>
<curr_code>USD</curr_code>
<ps_download>-400000000.000</ps_download>
</MyTable>
<MyTable>
<bs_group>Liabilities</bs_group>
<bs_categ>08.Deposits</bs_categ>
<curr_code>USD</curr_code>
<ps_download>-400000000.000</ps_download>
</MyTable>
<MyTable>
<bs_group>Liabilities</bs_group>
<bs_categ>08.Deposits</bs_categ>
<curr_code>USD</curr_code>
<ps_download>-400000000.000</ps_download>
</MyTable>
<MyTable>
<bs_group>Liabilities</bs_group>
<bs_categ>08.Deposits</bs_categ>
<curr_code>USD</curr_code>
<ps_download>-400000000.000</ps_download>
</MyTable>
<MyTable>
<bs_group>Liabilities</bs_group>
<bs_categ>08.Deposits</bs_categ>
<curr_code>USD</curr_code>
<ps_download>-400000000.000</ps_download>
</MyTable>
<MyTable>
<bs_group>Liabilities</bs_group>
<bs_categ>08.Deposits</bs_categ>
<curr_code>USD</curr_code>
<ps_download>-450000000.000</ps_download>
</MyTable>
<MyTable>
<bs_group>Liabilities</bs_group>
<bs_categ>08.Deposits</bs_categ>
<curr_code>USD</curr_code>
<ps_download>-455000000.000</ps_download>
</MyTable>
<MyTable>
<bs_group>Liabilities</bs_group>
<bs_categ>08.Deposits</bs_categ>
<curr_code>USD</curr_code>
<ps_download>-500000000.000</ps_download>
</MyTable>
<MyTable>
<bs_group>Liabilities</bs_group>
<bs_categ>08.Deposits</bs_categ>
<curr_code>USD</curr_code>
<ps_download>-500000000.000</ps_download>
</MyTable>
<MyTable>
<bs_group>Liabilities</bs_group>
<bs_categ>08.Deposits</bs_categ>
<curr_code>USD</curr_code>
<ps_download>-500000000.000</ps_download>
</MyTable>
<MyTable>
<bs_group>Liabilities</bs_group>
<bs_categ>08.Deposits</bs_categ>
<curr_code>USD</curr_code>
<ps_download>-500000000.000</ps_download>
</MyTable>
<MyTable>
<bs_group>Liabilities</bs_group>
<bs_categ>08.Deposits</bs_categ>
<curr_code>USD</curr_code>
<ps_download>-600000000.000</ps_download>
</MyTable>
<MyTable>
<bs_group>Liabilities</bs_group>
<bs_categ>08.Deposits</bs_categ>
<curr_code>USD</curr_code>
<ps_download>-604000000.000</ps_download>
</MyTable>
<MyTable>
<bs_group>Liabilities</bs_group>
<bs_categ>08.Deposits</bs_categ>
<curr_code>USD</curr_code>
<ps_download>-620500000.000</ps_download>
</MyTable>
<MyTable>
<bs_group>Liabilities</bs_group>
<bs_categ>08.Deposits</bs_categ>
<curr_code>USD</curr_code>
<ps_download>-660000000.000</ps_download>
</MyTable>
<MyTable>
<bs_group>Liabilities</bs_group>
<bs_categ>08.Deposits</bs_categ>
<curr_code>USD</curr_code>
<ps_download>-990000000.000</ps_download>
</MyTable>
<MyTable>
<bs_group>Liabilities</bs_group>
<bs_categ>08.Deposits</bs_categ>
<curr_code>USD</curr_code>
<ps_download>-1058000000.000</ps_download>
</MyTable>
<MyTable>
<bs_group>Liabilities</bs_group>
<bs_categ>08.Deposits</bs_categ>
<curr_code>USD</curr_code>
<ps_download>-1150000000.000</ps_download>
</MyTable>
<MyTable>
<bs_group>Liabilities</bs_group>
<bs_categ>08.Deposits</bs_categ>
<curr_code>USD</curr_code>
<ps_download>-1299000000.000</ps_download>
</MyTable>
<MyTable>
<bs_group>Liabilities</bs_group>
<bs_categ>08.Deposits</bs_categ>
<curr_code>USD</curr_code>
<ps_download>-1500000000.000</ps_download>
</MyTable>
<MyTable>
<bs_group>Liabilities</bs_group>
<bs_categ>09.FFP & REPOS</bs_categ>
<curr_code>USD</curr_code>
<ps_download>-5064000.000</ps_download>
</MyTable>
<MyTable>
<bs_group>Liabilities</bs_group>
<bs_categ>09.FFP & REPOS</bs_categ>
<curr_code>USD</curr_code>
<ps_download>-250000000.000</ps_download>
</MyTable>
<MyTable>
<bs_group>Liabilities</bs_group>
<bs_categ>09.FFP & REPOS</bs_categ>
<curr_code>USD</curr_code>
<ps_download>-1000000000.000</ps_download>
</MyTable>
<MyTable>
<bs_group>Liabilities</bs_group>
<bs_categ>09.FFP & REPOS</bs_categ>
<curr_code>USD</curr_code>
<ps_download>-1030000000.000</ps_download>
</MyTable>
<MyTable>
<bs_group>Liabilities</bs_group>
<bs_categ>10.Other Borrowings</bs_categ>
<curr_code>USD</curr_code>
<ps_download>-365000000.000</ps_download>
</MyTable>
<MyTable>
<bs_group>Liabilities</bs_group>
<bs_categ>10.Other Borrowings</bs_categ>
<curr_code>USD</curr_code>
<ps_download>-365000000.000</ps_download>
</MyTable>
<MyTable>
<bs_group>Liabilities</bs_group>
<bs_categ>10.Other Borrowings</bs_categ>
<curr_code>USD</curr_code>
<ps_download>-400000000.000</ps_download>
</MyTable>
<MyTable>
<bs_group>Liabilities</bs_group>
<bs_categ>10.Other Borrowings</bs_categ>
<curr_code>USD</curr_code>
<ps_download>-600000000.000</ps_download>
</MyTable>
<MyTable>
<bs_group>Liabilities</bs_group>
<bs_categ>11.Trading Liabilities</bs_categ>
<curr_code>EUR</curr_code>
<ps_download>219496.600</ps_download>
</MyTable>
<MyTable>
<bs_group>Liabilities</bs_group>
<bs_categ>11.Trading Liabilities</bs_categ>
<curr_code>JPY</curr_code>
<ps_download>-0.010</ps_download>
</MyTable>
<MyTable>
<bs_group>Liabilities</bs_group>
<bs_categ>11.Trading Liabilities</bs_categ>
<curr_code>USD</curr_code>
<ps_download>0.010</ps_download>
</MyTable>
<MyTable>
<bs_group>Liabilities</bs_group>
<bs_categ>11.Trading Liabilities</bs_categ>
<curr_code>USD</curr_code>
<ps_download>0.010</ps_download>
</MyTable>
<MyTable>
<bs_group>Liabilities</bs_group>
<bs_categ>11.Trading Liabilities</bs_categ>
<curr_code>USD</curr_code>
<ps_download>93193.000</ps_download>
</MyTable>
<MyTable>
<bs_group>Liabilities</bs_group>
<bs_categ>11.Trading Liabilities</bs_categ>
<curr_code>USD</curr_code>
<ps_download>206472.000</ps_download>
</MyTable>
<MyTable>
<bs_group>Liabilities</bs_group>
<bs_categ>11.Trading Liabilities</bs_categ>
<curr_code>USD</curr_code>
<ps_download>-0.030</ps_download>
</MyTable>
<MyTable>
<bs_group>Liabilities</bs_group>
<bs_categ>11.Trading Liabilities</bs_categ>
<curr_code>USD</curr_code>
<ps_download>-5888.000</ps_download>
</MyTable>
<MyTable>
<bs_group>Liabilities</bs_group>
<bs_categ>11.Trading Liabilities</bs_categ>
<curr_code>USD</curr_code>
<ps_download>-305686.520</ps_download>
</MyTable>
<MyTable>
<bs_group>Liabilities</bs_group>
<bs_categ>11.Trading Liabilities</bs_categ>
<curr_code>USD</curr_code>
<ps_download>-1788707.000</ps_download>
</MyTable>
<MyTable>
<bs_group>Liabilities</bs_group>
<bs_categ>12.Other Liabilities</bs_categ>
<curr_code>USD</curr_code>
<ps_download>-32.850</ps_download>
</MyTable>
<MyTable>
<bs_group>Liabilities</bs_group>
<bs_categ>12.Other Liabilities</bs_categ>
<curr_code>USD</curr_code>
<ps_download>-67.260</ps_download>
</MyTable>
<MyTable>
<bs_group>Liabilities</bs_group>
<bs_categ>12.Other Liabilities</bs_categ>
<curr_code>USD</curr_code>
<ps_download>-21991446.060</ps_download>
</MyTable>
<MyTable>
<bs_group>Liabilities</bs_group>
<bs_categ>12.Other Liabilities</bs_categ>
<curr_code>USD</curr_code>
<ps_download>-22959632.690</ps_download>
</MyTable>
</MyDataSet>
XSLT:
=====
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:key name="key-group" match="MyTable" use="bs_group"/>
<xsl:key name="key-group-bs_categ" match="MyTable" use="concat(bs_group,'+',bs_categ)"/>
<xsl:variable name="ps_download_asset_sub_total" select="sum(key('key-group','Assets')/ps_download)"></xsl:variable>
<xsl:variable name="ps_download_liab_sub_total" select="sum(key('key-group','Liabilities')/ps_download)"></xsl:variable>
<xsl:template match="/">
<xsl:apply-templates select="MyDataSet" />
</xsl:template>
<xsl:template match="MyDataSet">
<div>
<div id="CmnSpanSearchCriteria" ></div>
<div id="CmnListOverFlowDiv" style="width:820px;position:absolute;display:inlin e">
<TABLE width='800px' >
<tr>
<th id="bs_group" style="WIDTH:3%;" align='center' >BS Group </th>
<th id="bs_categ" style="WIDTH:5%;" align='center' >BS category </th>
<th id="curr_code" style="WIDTH:3%;" align='center' > Currency </th>
<th id="ps_download" style="WIDTH:4%;" align='center' > Amount </th>
</tr>
</TABLE>
<TABLE width='800px' >
<TBODY>
<xsl:apply-templates select="MyTable[curr_code='AUD']" >
<xsl:sort select="0" data-type="text" order="ascending" />
</xsl:apply-templates>
</TBODY>
</TABLE>
</div>
</div>
</xsl:template>
<xsl:template match="MyTable">
<tr>
<td style="WIDTH:3%;" > <xsl:value-of select="bs_group" /> </td>
<td style="WIDTH:5%"> <xsl:value-of select="bs_categ" /> </td>
<td style="WIDTH:3%;"> <xsl:value-of select="curr_code" /> </td>
<td align="right" style="WIDTH:4%;">
<xsl:value-of select="format-number(ps_download,'$#,###,###,###,###,###.000')"/>
</td>
</tr>
<xsl:if test="(following-sibling::MyTable[1]/bs_categ != bs_categ) or (following-sibling::MyTable[1]/bs_group != bs_group) or (position() = last())">
<xsl:variable name="ps_download_categ_sub_total" select="sum(key('key-group-bs_categ',concat(bs_group,'+',bs_categ))/ps_download)"></xsl:variable>
<tr >
<td colspan="3">Categ Total</td>
<td align="right" >
<xsl:value-of select="format-number($ps_download_categ_sub_total,'$#,###,###,## #,###,###.000')"/>
</td>
</tr>
</xsl:if>
<xsl:if test="(following-sibling::MyTable[1]/bs_group != bs_group) and (bs_group='Assets')">
<tr >
<td colspan="3">Total <xsl:value-of select="bs_group" /></td>
<td align="right">
<xsl:value-of select="format-number($ps_download_asset_sub_total,'$#,###,###,## #,###,###.000')"/>
</td>
</tr>
</xsl:if>
<xsl:if test="position() = last()">
<tr>
<td colspan="3">Total <xsl:value-of select="bs_group" /></td>
<td align="right">
<xsl:value-of select="format-number($ps_download_liab_sub_total,'$#,###,###,### ,###,###.000')"/>
</td>
</tr>
</xsl:if>
</xsl:template>
</xsl:stylesheet>
SS
__________________
SS
|