This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
RE: Find a set of nodes and depending on element values
- From: "Michael Kay" <michael dot h dot kay at ntlworld dot com>
- To: <xsl-list at lists dot mulberrytech dot com>
- Date: Mon, 4 Mar 2002 17:37:42 -0000
- Subject: RE: [xsl] Find a set of nodes and depending on element values
- Reply-to: xsl-list at lists dot mulberrytech dot com
> Now I want to find all <action> elements with the element
> <loadsize>1</loadsize> and then process the average time
> (<time>xxx</time>)
> for each set of action elements with the same time.
You'll have to explain yourself more clearly. The average time of a set of
elements with the same time is the average of a set of numbers that are all
the same.
I suspect you're trying to do the equivalent of the classic "sum of price
times quantity for all items". Solutions include:
(a) write a recursive named template
(b) (Saxon extension) saxon:sum(//item, saxon:expression("@price * @qty"))
(c) (XSLT 2.0, Saxon 7.0) sum(for $i in //item return $i/@price * $i/@qty)
Michael Kay
Software AG
home: Michael.H.Kay@ntlworld.com
work: Michael.Kay@softwareag.com
>
> <xsl:value-of select="sum(/time[loadsize='1']) div
> count(time[loadsize
> ='1'])"/> does not work...
>
> My problem is to find the correct nodeset - for-each gives
> me the strings
> , not the elements.
>
> thanks in advance!
>
> erik stunkat
>
>
> XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
>
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list