Without using tumbling windows, how is the position itself included in a result?
Obviously "$p" should be the "index" of each $item in $items. That being said, iteration isn't guaranteed to be sequential at all.
output:
<result>
<items>
<item pos="$p">5</item>
<item pos="$p">3</item>
<item pos="$p">7</item>
<item pos="$p">2</item>
<item pos="$p">7</item>
<item pos="$p">3</item>
</items>
</result>
query:
xquery version "3.1";
let $items := (5,3,7,2,7,3)
return
<result>
<items>
{
for $item in $items[position()]
let $p := position()
return <item pos="$p">{$item}</item>
}
</items>
</result>
query adapted from: