I´m trying to hold the iteration number in vars, but as you know, xQuery vars are immutable
There´s an special syntax like
for $film at $i in doc('films.xml')/films/film
return <film>{$i}.{data($film/@title)}</film>
My problem is, how to hold the value of the absolute iteration when a loop is inside another loop.
for $film at $i in doc('films.xml')/films/film
for $goofs at $j in $film/goofs/goof
return **total_absolute_number_goof**
I mean I dont need
i=1 j=1,2,3 i=1 j=1,2,3
i=2 j=1,2,3... but i=2 j=4,5,6
Is there any easy way to achieve that in xquery?
EDIT: java equivalent
int j = 0;
for (;some_external_condition;)
for (;some_external_condition;j++) {}
//j would print number of total iterations
There’s a feature in XQuery 3.0 to do this:
It’s already been added to some XQuery processors, for example Saxon-EE 9.4.
In XQuery 1.0 I think you would need two passes: first create the list of films, then number them.