|
[XQuery Talk Mailing List Archive Home] [By Date] [By Thread] [By Subject] [By Author] [Recent Entries] [Reply To This Message] problem with loopsMartin Probst martin at x-hive.comWed Jan 4 10:03:45 PST 2006
Hi,
> 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
> };
Your problem is that $QV1 is not "overwritten", you can't re-declare
variables in XQuery. Meaning: the first $QV1 is a completely different
variable than the second, the third etc. The variable declared within
the for loop "hides" the outer variable, and it is scoped to the loop.
So if you assign something to it, as soon as the loop iterates to the
next map, the value is lost and the $QV1 referenced in lcl:rend($QV1) is
again the variable from the outer statement.
You should try to rewrite your functions to get a more functional
approach, e.g. have lcl:rend and lcl:tracer return sequences which you
can iterate.
Martin
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|






