Re: [xsl] want to display sum of every two records

Subject: Re: [xsl] want to display sum of every two records
From: "Imsieke, Gerrit, le-tex" <gerrit.imsieke@xxxxxxxxx>
Date: Mon, 22 Feb 2010 09:33:09 +0100
Dear Kumar,

If your input looks like

<?xml version="1.0" encoding="utf-8"?>
  <mezo eazon="AA">200</mezo>
  <mezo eazon="AA">50</mezo>
  <mezo eazon="AA">300</mezo>
  <mezo eazon="AA">50</mezo>

you may transform it using the following XSLT (2.0):

<?xml version="1.0" encoding="utf-8"?>
  version="2.0"  >


  <xsl:template match="/">
    <xsl:apply-templates />

  <xsl:template match="doc">
      <xsl:for-each-group select="*"
        group-starting-with="*[position() mod 2 = 1]">
        <xsl:copy-of select="current-group()" />
        <mezo eazon="BB">
          <xsl:value-of select="sum(current-group())"/>



On 22.02.2010 09:09, anil kumar wrote:

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


-- Gerrit Imsieke Geschdftsf|hrer / Managing Director le-tex publishing services GmbH Weissenfelser Str. 84, 04229 Leipzig, Germany Phone +49 341 355356 110, Fax +49 341 355356 510 gerrit.imsieke@xxxxxxxxx,

Registergericht / Commercial Register: Amtsgericht Leipzig
Registernummer / Registration Number: HRB 24930

Geschdftsf|hrer: Gerrit Imsieke, Svea Jelonek,
Thomas Schmidt, Dr. Reinhard Vvckler

Current Thread