xsl-list
[Top] [All Lists]

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

2010-02-22 02:33:41
Dear Kumar,

If your input looks like

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

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

<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet
  xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
  version="2.0"  >

  <xsl:output
    method="xml"
    indent="yes"
    />

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

  <xsl:template match="doc">
    <xsl:copy>
      <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())"/>
        </mezo>
      </xsl:for-each-group>
    </xsl:copy>
  </xsl:template>

</xsl:stylesheet>


Gerrit


On 22.02.2010 09:09, anil kumar 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

--~------------------------------------------------------------------
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>
--~--


--
Gerrit Imsieke
Geschäftsfü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(_dot_)imsieke(_at_)le-tex(_dot_)de, http://www.le-tex.de

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

Geschäftsführer: Gerrit Imsieke, Svea Jelonek,
Thomas Schmidt, Dr. Reinhard Vöckler

--~------------------------------------------------------------------
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>
--~--

<Prev in Thread] Current Thread [Next in Thread>