1 Reply Latest reply: Feb 23, 2012 8:23 AM by odie_63 RSS

    Flexible FOR iteration in nested loop

    user8951048
      Hi everyone,
      I have a little challange with a FOR loop. A nested loop shall have a flexible iteration maximum that is calculated in the loop above. Till now, I get an exception for the use of variables in iteration header: {err}XP0006: "4 ({http://www.w3.org/2001/XMLSchema}decimal)": bad value for type {http://www.w3.org/2001/XMLSchema}integer

      My Code (shortend):

      for $loop1 at $loop1Count in $node1/node2
      return     
           for $loop2 at $loop2Count in $node2/node3
           return                                                  
                                         
           let $IntervalSize := fn:round-half-to-even(abs($num1 div $num2), 0)
                                         
           for $IntervalLoop at $Count in 1 to *$IntervalSize*
           return

      If I put an integer behind the variable "$IntervalSize" e.g. 3, than it works probably.
      Does someone know how to use the $IntervalSize as a maximum for the iteration count?

      Kind regards,
      S. Braendlin