From: Kasper F. <ka...@ea...> - 2005-04-05 13:29:37
|
Hi=20 I'm struggling with an eXist xquery where I want to make some calculations= =20 during a for loop. I want to make following xQuery. declare variable $total {xs:double(0)}; let $total :=3D 0 let $item :=3D collection('/db/items')/item return <items> { for $sub in $item let $total :=3D $sub/amount/@name+$total if($total>999) then=20 let $total:=3D$total-10 (:do something:) order by $sub/@id return <item> {$sub/} </item> } <sum name=3D"{$total}"/> </items> How can I achieve this ? I cannot use sum($item/amount/@name) because I need to evaluate $total in = the=20 for loop. Am I forced to register my own class to eXist class MyMaths(){ double value=3D0; double add(double in){ value+=3Din; return value; } double getValue(){ return value; } } TIA /Kasper =2D-=20 _______________________________________ Yours sincerely=20 Kasper Fock =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 EasySpeedy ApS Hoesterkoebvej 33, DK-2970 Hoersholm, Denmark Phone: +45 4594 1401 =A0 =A0=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0= =A0 =A0 =A0 =A0 =A0 =A0=20 http://EasySpeedy.com=A0=A0=A0 _______________________________________=20 Reliable Dedicated Server Hosting 24/7 Customer Self-Services available Multiple Linux and BSD distributions _______________________________________ |