This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Re[2]: how calculate sum(x*y)
- From: Andrey Solonchuk <solo at ibis dot odessa dot ua>
- To: "Jarno dot Elovirta at nokia dot com" <xsl-list at lists dot mulberrytech dot com>
- Date: Mon, 7 Oct 2002 12:04:01 +0300
- Subject: Re[2]: [xsl] how calculate sum(x*y)
- Organization: IBIS
- References: <E392EEA75EC5F54AB75229B693B1B6A70E2680@esebe018.ntc.nokia.com>
- Reply-to: xsl-list at lists dot mulberrytech dot com
Hello Jarno,
Monday, October 7, 2002, 11:25:50 AM, you wrote:
JEnc> Hi,
>> how calculate sum(x*y) ??
>>
>> IF i try use sum() it say that need only node-list as argument....
>>
>> I have xml
>> <root>
>> <data>
>> <x>2</x>
>> <y>3</y>
>> </data>
>> <data>
>> <x>5</x>
>> <y>6</y>
>> </data>
>> .....
>> <root>
JEnc> Write a recursive template, that goes through all the data elements, summing the multiplication result to previous result sum, i.e.
JEnc> template name=sum
JEnc> param name=node-set
JEnc> param name=sum
JEnc> if count($node-set') = 0
JEnc> then
JEnc> value-of select=$sum
JEnc> else
JEnc> call-template name=sum
JEnc> with-param name=node-set select=$node-set[not(position() = 1)]
JEnc> with-param name=sum select=$sum + $node-set[1]/x * $node-set[1]/y
JEnc> Dimitri probably has some suitable function for the job, see [http://fxsl.sourceforge.net/].
JEnc> Cheers,
JEnc> Jarno - Grendel: Human Saviour
JEnc> XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
I try now use function "nodeset" from xalan namespace to build new nodeset
with result of calculation x*y and then apply function sum for this
tree.
can you compare this two variants, what variant more likely to use ?
--
Best regards,
Andrey mailto:solo@ibis.odessa.ua
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list