[xquery-talk] problem with loops

Titash Neogi titash_neogi at symantec.com
Wed Jan 4 00:39:29 PST 2006


Hello All,

Happy New year!

My question is related to a programming problem that I am unable to
solve. Please refer to the code listed below

______________________________

declare function lcl:caller()
{

       let $QV1 := request:request-parameter("val1","")

       let $count:= 0

       let $QV1:= lcl:tracer($QV1)


       let $k:= lcl:rend($QV1)

       let $QV2:= $QV1/result/text()

       let $QV1:= lcl:tracer($k)


       let $k:= lcl:rend($QV1)

       let $QV3:= $QV1/result/text()

       let $QV1:= lcl:tracer($k)



       let $k:= lcl:rend($QV1)

       let $QV4:= $QV1/result/text()

       let $QV1:= lcl:tracer($k)

let $final:= concat($QV2," ",$QV3," ",$QV4)

return $final
};

____________________________

What I am trying to do here is calling two local functions (tracer and
rend) 3 times and storing the result in three variables QV2, QV3 and
QV4.

Now my problem starts when  I remove those three iterations and try to
implement a for loop that traverses through a xml document and stores
all the results in a single variable.

Something as shown below
____________________________________


declare function lcl:caller()
{

       let $QV1 := request:request-parameter("val1","")

       let $count:= 0

       let $QV1:= lcl:tracer($QV1)

for $d in /maps/map

       let $k:= lcl:rend($QV1)

       let $QV2:= $QV1

       let $QV1:= lcl:tracer($k)


       return $QV2




};
________________________________________

This doesnt work because all I get is the values returned by the
functions the first time, repeated n number of times.

I have tried to implement something like an array ( $QV[$index]:= $QV1
)  but that gives me a syntax error.

How do I implement this? Any ideas suggestions will be most helpful.

Thanks and Regards
Titash Neogi



More information about the talk mailing list