This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: XPath function after grouping


You grouped your Observation's by SiteNumber, so you can use this key for
sum() too:

<xsl:value-of select="sum(key('site_', SiteNumber)/Cond/value)"/>

Sums all Observation/Cond/value, which have the same current SiteNumber.

Result:

1:            19.4
130001:  10.2
2:              0


Regards,

Joerg

----- Original Message -----
From: "Michael Bauerfeld" <michael@socialchange.net.au>
To: <XSL-List@lists.mulberrytech.com>
Sent: Monday, January 21, 2002 1:12 AM
Subject: [xsl] XPath function after grouping


> I would like to use XPath function like sum() or count() for groups I've
> created with the Muenchian Method but I can't get it right to run a e.g.
> sum() for all members of a sub-group.
> Could someone give me a hint how to get it working?!
>
> Thanks,
> -Michael
>
>
> <?xml version="1.0" encoding="UTF-8"?>
> <Result>
> <Observation>
> <SiteNumber>1</SiteNumber>
> <Cond>
> <value>10.4</value>
> </Cond>
> </Observation>
> <Observation>
> <SiteNumber>130001</SiteNumber>
> <Cond>
> <value>10.2</value>
> </Cond>
> </Observation>
> <Observation>
> <SiteNumber>1</SiteNumber>
> <Cond>
> <value>9.0</value>
> </Cond>
> </Observation>
> <Observation>
> <SiteNumber>2</SiteNumber>
> <Cond>
> <value>0</value>
> </Cond>
> </Observation>
> </Result>
>
>
>
> <?xml version="1.0" encoding="UTF-8"?>
> <xsl:stylesheet version="1.0"
> xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
> xmlns:fo="http://www.w3.org/1999/XSL/Format";>
> <xsl:key name="site_" match="Members/Observation" use="SiteNumber"/>
> <xsl:template match="Result">
> <xsl:apply-templates select="Members/Observation[generate-id(.) =
> generate-id(key('site_', SiteNumber))]"/>
> </xsl:template>
> <xsl:template match="Observation">
> <xsl:value-of select="SiteNumber"/><br/>
> <xsl:value-of select="sum(????)"/>
> </xsl:template>
> </xsl:stylesheet>
>
>
>  XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
>


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]