Subject: Re: want to display sum of every two records
From: Mukul Gandhi <gandhi.mukul@xxxxxxxxx>
Date: Mon, 22 Feb 2010 14:15:32 +0530
|
I thought, this could have been accomplished as follows:
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="2.0">
<xsl:output method="xml" indent="yes" />
<xsl:template match="test">
<test>
<xsl:apply-templates select="mezo[1]" />
</test>
</xsl:template>
<xsl:template match="mezo">
<xsl:copy-of select="." />
<xsl:if test="(count(preceding-sibling::mezo) + 1) mod 2 eq 0">
<mezo eazon="BB"><xsl:value-of select=". +
preceding-sibling::mezo[1]" /></mezo>
</xsl:if>
<xsl:apply-templates select="following-sibling::mezo[1]" />
</xsl:template>
</xsl:stylesheet>
If the input document is, as follows:
<test>
<mezo eazon="AA">200</mezo>
<mezo eazon="AA">50</mezo>
<mezo eazon="AA">300</mezo>
<mezo eazon="AA">50</mezo>
</test>
The output of the above transform is:
<?xml version="1.0" encoding="UTF-8"?>
<test>
<mezo eazon="AA">200</mezo>
<mezo eazon="AA">50</mezo>
<mezo eazon="BB">250</mezo>
<mezo eazon="AA">300</mezo>
<mezo eazon="AA">50</mezo>
<mezo eazon="BB">350</mezo>
</test>
On Mon, Feb 22, 2010 at 1:39 PM, anil kumar <anar.leti@xxxxxxxxx> wrote:
> Hi,
>
> B want to display the column BB as sum of B every two records
>
> my o/p should be like below..
>
> <mezo eazon="AA">200</mezo>
> <mezo eazon="AA">50</mezo>
> <mezo eazon="BB">250</mezo>
> <mezo eazon="AA">300</mezo>
> <mezo eazon="AA">50</mezo>
> <mezo eazon="BB">350</mezo>
>
> iam breaking my head to get the above o/p.
>
> any suggestions ..Can you get it through XSL
>
> Thanks
> Kumar
--
Regards,
Mukul Gandhi
|