Subject:counter in xquery Author:Tony Lavinio Date:27 Mar 2007 11:54 AM
You almost had it.
for $i in (1 to 10)
return <value>{ $i }</value>
But you must stop thinking procedurally.
Variables don't change value in XQuery, just like they don't in XSLT.
But you can assign them to a whole sequence of values, including a
sequence of nodes.
Subject:counter in xquery Author:Tony Lavinio Date:27 Mar 2007 04:34 PM
Then you're not thinking about the problem right.
Think about the result as a set, not as a list of
items to be iterated through.
The 'for' in XQuery doesn't mean 'walk through the
list of items matching the criteria one by one'.
Instead it means 'I've already selected the entire
set of data, now I'm going to apply some operation
to all of them.'
Maybe if you provided a little more information, such
as what your input looks like and what your output is
supposed to look like, we can help.