Reputation: 327
If i'm having 'n' number of nodes and i want to assign a number from starting of the node to 'n' number of nodes. example:
<entity>
<result>
<seq>1</seq>
</result>
<result>
<seq>2</seq>
</result>
<result>
<seq>3</seq>
</result>
....
....
....
<result>
<seq>n</seq>
</result>
</entity>
Upvotes: 0
Views: 2639
Reputation: 355
Use the at keyword to count the iteration.
let $list := (20, 23, 25, 24, 22, 21)
return
<entity>
{
for $n at $seq in $list
return
<result><seq>{$seq}</seq><value>{$n}</value></result>
}
</entity>
Upvotes: 1
Reputation: 38712
If the example is what you want as result, try this:
<entity>
{
for $n in 1 to 10
return
<result><seq>{$n}</seq></result>
}
</entity>
Otherwise, rewrite your question so it contains
Also, do you want to update you document (XQuery Update) or only enrich the output?
Upvotes: 2