[Xquery] How to do a increment in a For loop


 
Thread Tools Search this Thread
Top Forums Programming [Xquery] How to do a increment in a For loop
# 1  
Old 12-11-2011
[Xquery] How to do a increment in a For loop

Hello men.

How can i build a simple increment for $a by Xquery such as ?
Code:
let $a := 0
for $i in (1 to 10)
let $a := $a + 1
return $a

why a in this loop always is '1'

Thank you for reading, its will really helpful for my job if i can solve this problem SmilieSmilie

Last edited by jim mcnamara; 12-12-2011 at 12:26 PM.. Reason: please use code tags
# 2  
Old 12-12-2011
There are several ways to do this:
Code:
for a in $(seq 1 10); do
    echo $a
done

or
Code:
a=0
while [[ ${a} -le 10 ]]; do
    a=$(expr ${a} + 1)
done

or
Code:
a=0
while [[ ${a} -le 10 ]]; do
    (( a = a+ 1 ))
done

or ... any others?
# 3  
Old 12-12-2011
hi i test by stylus studio 2010, your code not work at all. Is there some version of Xquery ?
# 4  
Old 12-12-2011
I do apologize, I skipped right over the 'XQuery' requirement.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Parallel increment of nested for loop

Hi, I am using solaris 5.10 environment and need help on doing parallel increment of nested for loop. Samples #inside the code the values assigned to a variable by another awk command will be like a=/xyz/pg/as /xyz/pg/as2 /xyz/pg/as3 b=/xyz/sd/fd1 /xyz/sd/fd2 /xyz/sd/fd3 for q in... (1 Reply)
Discussion started by: ananan
1 Replies

2. Windows & DOS: Issues & Discussions

Batch file loop and increment value for condition

I am trying to have the below batch file do following two things: 1. only allow the values YES,yes,Y,y, or NO,no,N,n 2. increment the counter %var1 only if answer to question 2 is "y" and not able to get the syntax correct. If %var1%=1 then I am trying to display function :end. Thank you :).... (0 Replies)
Discussion started by: cmccabe
0 Replies

3. Shell Programming and Scripting

Find and increment at each occurence of string (loop)

I created script (sh shell) to generate vlc playlist based on some data files. All works fine so far except one string I do not know how to handle with. VLCSTART='<vlc:id>' VLCV=0 VLCEND='</vlc:id>' echo -e $'\n'$'\t'$'\t'$'\t'$'\t'\$VLCSTART$VLCV$VLCENDOutput file contains several occurences... (10 Replies)
Discussion started by: TiedCone
10 Replies

4. Shell Programming and Scripting

[Solved] How to increment and add variable length numbers to a variable in a loop?

Hi All, I have a file which has hundred of records with fixed number of fields. In each record there is set of 8 characters which represent the duration of that activity. I want to sum up the duration present in all the records for a report. The problem is the duration changes per record so I... (5 Replies)
Discussion started by: danish0909
5 Replies

5. Shell Programming and Scripting

How to increment date using "for loop" in format MMDDYY inside the shell script?

Need to increment the date from "currentdate + 90days" inside the for loop (i=1 to i=50) (5 Replies)
Discussion started by: aroragaurav.84
5 Replies

6. Shell Programming and Scripting

For/While Loop to Increment Filenames in a Script

Daily stupid question. I want to increment the file name everytime the script is run. So for example if the filename is manager.log and I run the script, I want the next sequence to be manager.log1. So to be clear I only want it to increment when the script is executed. So ./script... (10 Replies)
Discussion started by: metallica1973
10 Replies

7. Programming

[XQuery] How to Convert from JSON Message to XML Message with XQuery

Hi guys, I'm in a job of converting a restful webservice to soap. Tool for convertation uses XQuery. Now i need to convert a message like this: { "firstName": "John", "midName": null, "lastName": "Smith", "married": false, "address": { "streetAddress": "21 2nd... (5 Replies)
Discussion started by: tien86
5 Replies

8. Shell Programming and Scripting

Increment nested for loop parllely

Hi , I am trying to increment the nested for loops parellely,but i cant ,i used continue 2 but the second loop not getting increment. no1="1 6 5 4 8" no2="4 7 8 0 1" for var1 in $no1 ; do for var2 in $no2 ; do line1 line 2 line 3 continue 2 done done Please help on this (4 Replies)
Discussion started by: nmahendran
4 Replies

9. Shell Programming and Scripting

the given code goes in infinite loop and does not increment variable i

code is as #!/bin/sh i=1; while do welcome $i times; i='expr $i+1'; done exit 0; (6 Replies)
Discussion started by: mrityunjay22
6 Replies

10. Shell Programming and Scripting

Increment date in 'for' loop?

Hi Guys, My first post..:) Right...I want to move existing files (with some date in their name) currently in $mainftp, to $mainfolder/$foldate/system1. I'd like to be able to increment date in the for loop? Is this possible or should I use a different technique. The script return the... (4 Replies)
Discussion started by: SunnyK
4 Replies
Login or Register to Ask a Question