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(_dot_)leti(_at_)gmail(_dot_)com> wrote:
Hi,
want to display the column BB as sum of 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
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--