Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


Re: Collecting data in each line Options

From: heshamelesawy@-----.---
To: NULL
Date: 6/26/2008 10:52:00 AM
On Jun 26, 2:50=A0pm, "Joe Fawcett" <joefawc...@newsgroup.nospam> wrote:
> <heshameles...@gmail.com> wrote in message
>
> news:3dc31f09-4c8e-42a8-b643-16a481d0b03c@m......
>
>
>
> > On Jun 26, 10:35 am, "Joe Fawcett" <joefawc...@newsgroup.nospam>
> > wrote:
> >> <heshameles...@gmail.com> wrote in message
>
> >>news:c9937992-2f37-4d12-ba03-45c5b10dfd21@5.....=
.
>
> >> > I need to write xsl document to collect data csv:field[4] for each
> >> > line groubing by
> >> > csv:field[1]
>
> >> > <csv:line>
> >> > <csv:field>48</csv:field>
> >> > <csv:field>20</csv:field>
> >> > <csv:field>6</csv:field>
> >> > <csv:field>6430</csv:field>
> >> > </csv:line>
> >> > <csv:line>
> >> > <csv:field>23</csv:field>
> >> > <csv:field>18</csv:field>
> >> > <csv:field>5</csv:field>
> >> > <csv:field>4621</csv:field>
> >> > </csv:line>
> >> > <csv:line>
> >> > <csv:field>48</csv:field>
> >> > <csv:field>23</csv:field>
> >> > <csv:field>198</csv:field>
> >> > <csv:field>5770</csv:field>
> >> > </csv:line>
> >> > <csv:line>
> >> > <csv:field>25</csv:field>
> >> > <csv:field>27</csv:field>
> >> > <csv:field>7</csv:field>
> >> > <csv:field>8873</csv:field>
> >> > </csv:line>
>
> >> In XSLT 2.0 use for-each-group, in XSLT 1.0 search for Muenchian
> >> Grouping.
>
> >> --
>
> >> Joe Fawcett (MVP - XML)http://joe.fawcett.name-Hide quoted text -
>
> >> - Show quoted text -
>
> > Sorry for duplicted message but i was think the message is not in
> > right Topic
>
> > I tried to do it like that
>
> > <xsl:for-each-group select=3D"csv:line" group-by=3D"csv:field[1]">
> > <xsl:element name=3D"element">
> > <xsl:attribute name=3D"Id">ID</xsl:attribute>
> > <xsl:value-of select=3D"csv:field[1]"/>
> > </xsl:element>
> > <xsl:element name=3D"element">
> > <xsl:attribute name=3D"Id">Sum</xsl:attribute>
> > <xsl:value-of select=3D"sum(csv:field[4])"/>
> > </xsl:element>
> > </xsl:for-each-group>
>
> > but it didnt get the sum value its gust get the csv:field[4] for first
> > line only
>
> Not exactly sure what you want but try this:
> <?xml version=3D"1.0" encoding=3D"UTF-8" ?>
> <xsl:stylesheet version=3D"2.0"
> =A0 xmlns:xsl=3D"http://www.w3.org/1999/XSL/Transform"
> xmlns:csv=3D"http://tempuri.com" exclude-result-prefixes=3D"csv">
> =A0 <xsl:template match=3D"/csv:data">
> =A0 =A0 <output>
> =A0 =A0 =A0 <xsl:for-each-group select=3D"csv:line" group-by=3D"csv:field=
[1]">
> =A0 =A0 =A0 =A0 <element Id=3D"ID">
> =A0 =A0 =A0 =A0 =A0 <xsl:value-of select=3D"current-grouping-key()"/>
> =A0 =A0 =A0 =A0 </element>
> =A0 =A0 =A0 =A0 <element Id=3D"Sum">
> =A0 =A0 =A0 =A0 =A0 <xsl:value-of select=3D"sum(current-group()/csv:field=
[4])"/>
> =A0 =A0 =A0 =A0 </element>
> =A0 =A0 =A0 </xsl:for-each-group>
> =A0 =A0 </output>
> =A0 </xsl:template>
> </xsl:stylesheet>
>
> against this xml:
> <csv:data xmlns:csv=3D"http://tempuri.com">
> <csv:line>
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 <csv:field>48</csv:field>
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 <csv:field>20</csv:field>
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 <csv:field>6</csv:field>
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 <csv:field>6430</csv:field>
> =A0 =A0 =A0 =A0 </csv:line>
> =A0 =A0 =A0 =A0 <csv:line>
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 <csv:field>23</csv:field>
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 <csv:field>18</csv:field>
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 <csv:field>5</csv:field>
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 <csv:field>4621</csv:field>
> =A0 =A0 =A0 =A0 </csv:line>
> =A0 =A0 =A0 =A0 <csv:line>
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 <csv:field>48</csv:field>
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 <csv:field>23</csv:field>
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 <csv:field>198</csv:field>
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 <csv:field>5770</csv:field>
> =A0 =A0 =A0 =A0 </csv:line>
> =A0 =A0 =A0 =A0 <csv:line>
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 <csv:field>25</csv:field>
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 <csv:field>27</csv:field>
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 <csv:field>7</csv:field>
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 <csv:field>8873</csv:field>
> =A0 =A0 =A0 =A0 </csv:line>
>
> </csv:data>
>
> --
>
> Joe Fawcett (MVP - XML)http://joe.fawcett.name- Hide quoted text -
>
> - Show quoted text -


It=92s Working
Thanks for help

I have another question.
For each element in the group I need to get ceiling of divide
operation then get the summation for group element
I tried this code but it=92s doesn=92t work

<xsl:value-of select=3D"sum(ceiling(current-group()/csv:field[4] div
1000))"/>


transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent