I'm trying to group my results by a preceding node where this node contains the MasterCard or Visa. As you can see form the html generated, there are 3 sub-schemes for mastercard and visa. I want to group the html by the parent scheme mastercard and visa only which will display 2 card schemes. Any help on this would be greatly appreciated.
Dimitre, the desired result is to display 1 row of card schemes for MasterCard and 1 row for Visa. Currently there are 3 each cause it displays the 3 subschemes for each.
Here is my XML:
<root>
<filetype>Report</filetype>
<recipient>Customer</recipient>
<creation-date>20 Sep 2010 12:30:27</creation-date>
<activation-date>21 Sep 2010 00:00:00</activation-date>
<imported-by>User</imported-by>
<p-r-ps>
<p-r-p meta='MyCompany' >
<cs>
<c meta='US Dollar' c-i='5170' >
<p-ss>
<p-s-n meta='Mastercard' p-s-c='MC' p-s-i='4' >
<c-ss>
<c-s-n meta='MasterCard Debit' c-s-c='MCD' c-s-i='5' d-m='0.060000' >
<b-cs>
<b-c meta='CZK' b-c-n='Czech Koruna' b-c-i-n='203' >
<f-cs>
<f-c>
<f-c-c meta='GBP' f-c-n='Pound Sterling' f-c-i-n='826' >
<r>
<i-e-r>False</i-e-r>
<i-m-e>False</i-m-e>
<prp-r>1</prp-r>
<p-u-a>0.000000</p-u-a>
<m-a-r>0</m-a-r>
<psp-r>1.000000</psp-r>
<lr>0.00</lr>
<ur>999999999999999.999</ur>
<e-r-e-m>1.000000</e-r-e-m>
<e-r-i-m>1.0600000</e-r-i-m>
<m-p>0.060000</m-p>
</r>
</f-c-c>
</f-c>
</f-cs>
</b-c>
</b-cs>
</c-s-n>
<c-s-n meta='Maestro' c-s-c='MA' c-s-i='2' d-m='0.060000' >
<b-cs>
<b-c meta='CZK' b-c='CZK' b-c-n='Czech Koruna' >
<f-cs>
<f-c>
<f-c-c meta='GBP' f-c-n='Pound Sterling' f-c-i-n='826' >
<r>
<i-e-r>False</i-e-r>
<i-m-e>False</i-m-e>
<prp-r>1</prp-r>
<p-u-a>0.000000</p-u-a>
<m-a-r>0</m-a-r>
<psp-r>1.000000</psp-r>
<lr>0.00</lr>
<ur>999999999999999.999</ur>
<e-r-e-m>1.000000</e-r-e-m>
<e-r-i-m>1.0600000</e-r-i-m>
<m-p>0.060000</m-p>
</r>
</f-c-c>
</f-c>
</f-cs>
</b-c>
</b-cs>
</c-s-n>
<c-s-n meta='Mastercard' c-s-c='MC' c-s-i='1' d-m='0.060000' >
<b-cs>
<b-c meta='CZK' b-c='CZK' b-c-n='Czech Koruna' >
<f-cs>
<f-c>
<f-c-c meta='GBP' f-c-n='Pound Sterling' f-c-i-n='826' >
<r>
<i-e-r>False</i-e-r>
<i-m-e>False</i-m-e>
<prp-r>1</prp-r>
<p-u-a>0.000000</p-u-a>
<m-a-r>0</m-a-r>
<psp-r>1.000000</psp-r>
<lr>0.00</lr>
<ur>999999999999999.999</ur>
<e-r-e-m>1.000000</e-r-e-m>
<e-r-i-m>1.0600000</e-r-i-m>
<m-p>0.060000</m-p>
</r>
</f-c-c>
</f-c>
</f-cs>
</b-c>
</b-cs>
</c-s-n>
</c-ss>
</p-s-n>
<p-s-n meta='Visa' p-s-c='VI' p-s-i='5' >
<c-ss>
<c-s-n meta='Electron' c-s-c='EL' c-s-i='3' d-m='0.060000' >
<b-cs>
<b-c meta='CZK' b-c='CZK' b-c-n='Czech Koruna' >
<f-cs>
<f-c>
<f-c-c meta='GBP' f-c-n='Pound Sterling' f-c-i-n='826' >
<r>
<i-e-r>False</i-e-r>
<i-m-e>False</i-m-e>
<prp-r>1</prp-r>
<p-u-a>0.000000</p-u-a>
<m-a-r>0</m-a-r>
<psp-r>1.000000</psp-r>
<lr>0.00</lr>
<ur>999999999999999.999</ur>
<e-r-e-m>1.000000</e-r-e-m>
<e-r-i-m>1.0600000</e-r-i-m>
<m-p>0.060000</m-p>
</r>
</f-c-c>
</f-c>
</f-cs>
</b-c>
</b-cs>
</c-s-n>
<c-s-n meta='Delta' c-s-c='DL' c-s-i='2' d-m='0.060000' >
<b-cs>
<b-c meta='CZK' b-c='CZK' b-c-n='Czech Koruna' >
<f-cs>
<f-c>
<f-c-c meta='GBP' f-c-n='Pound Sterling' f-c-i-n='826' >
<r>
<i-e-r>False</i-e-r>
<i-m-e>False</i-m-e>
<prp-r>1</prp-r>
<p-u-a>0.000000</p-u-a>
<m-a-r>0</m-a-r>
<psp-r>1.000000</psp-r>
<lr>0.00</lr>
<ur>999999999999999.999</ur>
<e-r-e-m>1.000000</e-r-e-m>
<e-r-i-m>1.0600000</e-r-i-m>
<m-p>0.060000</m-p>
</r>
</f-c-c>
</f-c>
</f-cs>
</b-c>
</b-cs>
</c-s-n>
<c-s-n meta='Visa' c-s-c='VI' c-s-i='1' d-m='0.060000' >
<b-cs>
<b-c meta='CZK' b-c='CZK' b-c-n='Czech Koruna' >
<f-cs>
<f-c>
<f-c-c meta='GBP' f-c-n='Pound Sterling' f-c-i-n='826' >
<r>
<i-e-r>False</i-e-r>
<i-m-e>False</i-m-e>
<prp-r>1</prp-r>
<p-u-a>0.000000</p-u-a>
<m-a-r>0</m-a-r>
<psp-r>1.000000</psp-r>
<lr>0.00</lr>
<ur>999999999999999.999</ur>
<e-r-e-m>1.000000</e-r-e-m>
<e-r-i-m>1.0600000</e-r-i-m>
<m-p>0.060000</m-p>
</r>
</f-c-c>
</f-c>
</f-cs>
</b-c>
</b-cs>
</c-s-n>
</c-ss>
</p-s-n>
</p-ss>
</c>
<c meta='Polish Zloty' c-i='5169' >
<p-ss>
<p-s-n meta='Mastercard' p-s-c='MC' p-s-i='4' >
<c-ss>
<c-s-n meta='MasterCard Debit' c-s-c='MCD' c-s-i='5' d-m='0.060000' >
<b-cs>
<b-c meta='PLN' b-c='PLN' b-c-n='Zloty' >
<f-cs>
<f-c>
<f-c-c meta='GBP' f-c-n='Pound Sterling' f-c-i-n='826' >
<r>
<i-e-r>False</i-e-r>
<i-m-e>False</i-m-e>
<prp-r>0.2169100</prp-r>
<p-u-a>0.000000</p-u-a>
<m-a-r>0</m-a-r>
<psp-r>0.2169100</psp-r>
<lr>0.00</lr>
<ur>999999999999999.999</ur>
<e-r-e-m>0.2169100</e-r-e-m>
<e-r-i-m>0.2299246</e-r-i-m>
<m-p>0.060000</m-p>
</r>
</f-c-c>
</f-c>
</f-cs>
</b-c>
</b-cs>
</c-s-n>
<c-s-n meta='Maestro' c-s-c='MA' c-s-i='2' d-m='0.060000' >
<b-cs>
<b-c meta='PLN' b-c='PLN' b-c-n='Zloty' >
<f-cs>
<f-c>
<f-c-c meta='GBP' f-c-n='Pound Sterling' f-c-i-n='826' >
<r>
<i-e-r>False</i-e-r>
<i-m-e>False</i-m-e>
<prp-r>0.2169100</prp-r>
<p-u-a>0.000000</p-u-a>
<m-a-r>0</m-a-r>
<psp-r>0.2169100</psp-r>
<lr>0.00</lr>
<ur>999999999999999.999</ur>
<e-r-e-m>0.2169100</e-r-e-m>
<e-r-i-m>0.2299246</e-r-i-m>
<m-p>0.060000</m-p>
</r>
</f-c-c>
</f-c>
</f-cs>
</b-c>
</b-cs>
</c-s-n>
<c-s-n meta='Mastercard' c-s-c='MC' c-s-i='1' d-m='0.060000' >
<b-cs>
<b-c meta='PLN' b-c='PLN' b-c-n='Zloty' >
<f-cs>
<f-c>
<f-c-c meta='GBP' f-c-n='Pound Sterling' f-c-i-n='826' >
<r>
<i-e-r>False</i-e-r>
<i-m-e>False</i-m-e>
<prp-r>0.2169100</prp-r>
<p-u-a>0.000000</p-u-a>
<m-a-r>0</m-a-r>
<psp-r>0.2169100</psp-r>
<lr>0.00</lr>
<ur>999999999999999.999</ur>
<e-r-e-m>0.2169100</e-r-e-m>
<e-r-i-m>0.2299246</e-r-i-m>
<m-p>0.060000</m-p>
</r>
</f-c-c>
</f-c>
</f-cs>
</b-c>
</b-cs>
</c-s-n>
</c-ss>
</p-s-n>
<p-s-n meta='Visa' p-s-c='VI' p-s-i='5' >
<c-ss>
<c-s-n meta='Electron' c-s-c='EL' c-s-i='3' d-m='0.060000' >
<b-cs>
<b-c meta='PLN' b-c='PLN' b-c-n='Zloty' >
<f-cs>
<f-c>
<f-c-c meta='GBP' f-c-n='Pound Sterling' f-c-i-n='826' >
<r>
<i-e-r>False</i-e-r>
<i-m-e>False</i-m-e>
<prp-r>0.2169100</prp-r>
<p-u-a>0.000000</p-u-a>
<m-a-r>0</m-a-r>
<psp-r>0.2169100</psp-r>
<lr>0.00</lr>
<ur>999999999999999.999</ur>
<e-r-e-m>0.2169100</e-r-e-m>
<e-r-i-m>0.2299246</e-r-i-m>
<m-p>0.060000</m-p>
</r>
</f-c-c>
</f-c>
</f-cs>
</b-c>
</b-cs>
</c-s-n>
<c-s-n meta='Delta' c-s-c='DL' c-s-i='2' d-m='0.060000' >
<b-cs>
<b-c meta='PLN' b-c='PLN' b-c-n='Zloty' >
<f-cs>
<f-c>
<f-c-c meta='GBP' f-c-n='Pound Sterling' f-c-i-n='826' >
<r>
<i-e-r>False</i-e-r>
<i-m-e>False</i-m-e>
<prp-r>0.2169100</prp-r>
<p-u-a>0.000000</p-u-a>
<m-a-r>0</m-a-r>
<psp-r>0.2169100</psp-r>
<lr>0.00</lr>
<ur>999999999999999.999</ur>
<e-r-e-m>0.2169100</e-r-e-m>
<e-r-i-m>0.2299246</e-r-i-m>
<m-p>0.060000</m-p>
</r>
</f-c-c>
</f-c>
</f-cs>
</b-c>
</b-cs>
</c-s-n>
<c-s-n meta='Visa' c-s-c='VI' c-s-i='1' d-m='0.060000' >
<b-cs>
<b-c meta='PLN' b-c='PLN' b-c-n='Zloty' >
<f-cs>
<f-c>
<f-c-c meta='GBP' f-c-n='Pound Sterling' f-c-i-n='826' >
<r>
<i-e-r>False</i-e-r>
<i-m-e>False</i-m-e>
<prp-r>0.2169100</prp-r>
<p-u-a>0.000000</p-u-a>
<m-a-r>0</m-a-r>
<psp-r>0.2169100</psp-r>
<lr>0.00</lr>
<ur>999999999999999.999</ur>
<e-r-e-m>0.2169100</e-r-e-m>
<e-r-i-m>0.2299246</e-r-i-m>
<m-p>0.060000</m-p>
</r>
</f-c-c>
</f-c>
</f-cs>
</b-c>
</b-cs>
</c-s-n>
</c-ss>
</p-s-n>
</p-ss>
</c>
</cs>
</p-r-p>
</p-r-ps>
</root>
And here my XSLT:
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:msxsl="urn:schemas-microsoft-com:xslt" xmlns:user="urn:user" exclude-result-prefixes="msxsl user" version="1.0">
<xsl:template match="/">
<!-- Build the master table to display our report in -->
<table border="0" width="650">
<tr>
<td>
<h1>Exchange Rate Report</h1>
</td>
</tr>
<tr>
<td>
<!-- Display the import summary information -->
<table border="0" width="100%" id="TableBorderless">
<tr>
<td class="LightGrayLeftAlign">Customer:</td>
<td><b><xsl:value-of select="root/recipient"/></b></td>
</tr>
<tr>
<td class="LightGrayLeftAlign">Activated On:</td>
<td><xsl:value-of select="root/activation-date"/></td>
</tr>
<tr>
<td width="25%" class="LightGrayLeftAlign">Imported On:</td>
<td width="75%"><xsl:value-of select="root/creation-date"/></td>
</tr>
<tr>
<td class="LightGrayLeftAlign">Imported By:</td>
<td><xsl:value-of select="root/imported-by"/></td>
</tr>
</table>
<br />
</td>
</tr>
<!-- Apply the template the generate the processing rate provider information -->
<xsl:apply-templates select="/root/p-r-ps/p-r-p"/>
</table>
</xsl:template>
<xsl:template match="p-r-p">
<tr>
<td>
<table width="100%" align="right" id="TableBorder">
<!-- Apply the company template sorted by the meta attribute -->
<xsl:apply-templates select="cs/c">
<xsl:sort select="@meta"/>
</xsl:apply-templates>
</table>
</td>
</tr>
</xsl:template>
<xsl:template match="c">
<tr>
<!-- Display the company name using the attribute of the company -->
<!-- and the processing rate providers XML elements -->
<th><xsl:value-of select="@meta"/></th>
</tr>
<tr>
<td>
<table width="99%" align="right" id="TableBorder">
<!-- Apply the parent-scheme-name template sorted by the meta attribute -->
<xsl:apply-templates select="p-ss/p-s-n">
<xsl:sort select="@meta"/>
</xsl:apply-templates>
</table>
</td>
</tr>
<tr>
<td> </td>
</tr>
</xsl:template>
<xsl:template match="p-s-n">
<tr>
<td>
<table width="99%" align="right" id="TableBorder">
<!-- Apply the child-scheme-name template sorted by the meta attribute -->
<xsl:apply-templates select="c-ss/c-s-n">
<xsl:sort select="@meta"/>
</xsl:apply-templates>
</table>
</td>
</tr>
</xsl:template>
<xsl:template match="c-s-n">
<tr>
<!-- Display the parent credit card name and the child credit card name -->
<th><xsl:value-of select="../../@meta"/>-<xsl:value-of select="@meta"/></th>
</tr>
<tr>
<td>
<!-- Apply the base-currency template sorted by the base-currency-name attribute -->
<xsl:apply-templates select="b-cs/b-c">
<xsl:sort select="@b-c-n"/>
</xsl:apply-templates>
</td>
</tr>
</xsl:template>
<xsl:template match="b-c">
<table width="98%" align="right" id="TableBorder">
<tr>
<!-- Display the base currency name -->
<td colSpan="8">Base Currency: <xsl:value-of select="@b-c-n"/></td>
</tr>
<tr>
<!-- Display the base currency table headings -->
<th class="LeftAlign">Foreign</th>
<th class="CenterAlign">PRP Rate</th>
<th class="CenterAlign">Manual Rate</th>
<th class="CenterAlign">MRA %</th>
<th class="CenterAlign">PSP Rate</th>
<th class="CenterAlign">Break Lower</th>
<th class="CenterAlign">Break Upper</th>
<th class="CenterAlign">Margin</th>
<th class="CenterAlign">Rate</th>
</tr>
<!-- Display a row for each base currency detailing the rate importation information -->
<xsl:for-each select="f-cs/f-c/f-c-c/r">
<tr>
<td><xsl:value-of select="../@meta"/></td>
<td align="right"><xsl:value-of select="user:FormatCurrencyNoAbbrev(string(prp-r), 7)"/></td>
<td align="right"><xsl:value-of select="user:FormatCurrencyNoAbbrev(string(m-a-r), 7)"/></td>
<td align="right"><xsl:value-of select="user:FormatPercentage(string(p-u-a), 2)"/></td>
<td align="right"><xsl:value-of select="user:FormatCurrencyNoAbbrev(string(psp-r), 7)"/></td>
<td align="right"><xsl:value-of select="user:FormatBreakValue(string(lr))"/></td>
<td align="right"><xsl:value-of select="user:FormatBreakValue(string(ur))"/></td>
<td align="right"><xsl:value-of select="user:FormatPercentage(string(m-p), 4)"/></td>
<td align="right"><xsl:value-of select="user:FormatCurrencyNoAbbrev(string(e-r-i-m), 7)"/></td>
</tr>
</xsl:for-each>
</table>
</xsl:template>
<msxsl:script language="VBScript" implements-prefix="user">
<![CDATA[
Function FormatCurrency(dblAmount, nExponent, strCurrAbbrev)
FormatCurrency = formatnumber(cdbl(dblAmount), cint(nExponent)) & " " & strCurrAbbrev
End Function
Function FormatCurrencyNoAbbrev(dblAmount, nExponent)
FormatCurrencyNoAbbrev = formatnumber(cdbl(dblAmount), cint(nExponent))
End Function
Function FormatBreakValue(dblBreakAmount)
dim strTempAmount
strTempAmount = cstr(dblBreakAmount)
if strTempAmount = "0" then
FormatBreakValue = "min "
elseif strTempAmount = "999999999999999.999" or strTempAmount = "999999999999999.99" then
FormatBreakValue = " max"
else
FormatBreakValue = dblBreakAmount
end if
End Function
Function FormatPercentage(dblAmount, nExponent)
FormatPercentage = formatnumber(cdbl(dblAmount)*100, cint(nExponent)) & "%"
End Function
Function FormatDate(strDate)
FormatDate = mid(strDate, 9, 2) & "-" & mid(strDate, 6, 2) & "-" & left(strDate, 4)
End Function
]]>
</msxsl:script>
</xsl:stylesheet>