I'd been wondering whether there was a way in a FLWOR statement to get the index position. I'd tried a few things that I'd hoped might work but I couldn't find a decent way to get back to the context whenever I got to the return portion of the statement.
It became apparent that in some (not all) contexts, I could rely on this example as a quick (and cheap) workaround:
Update - John Snelson advised me on the correct way to deal with position in XQuery - using for and at when starting the FLWOR statement:
Also worth considering:
And another useful positional trick, suggested by Jason Booth:
- ► 2011 (35)
- XQDT: Notes for installing the current Milestone o...
- MarkLogic: XQuery: performance with Maps
- Java: Using Jersey with JAXB to output XML or JSON...
- MarkLogic: XQuery: hacking the position() - a basi...
- MarkLogic: XQuery: and / and-not query examples
- MarkLogic: XQuery: UNIX Timestamp to xs:dateTime C...
- MarkLogic: XCC/J: Passing a node() into a Query as...
- MarkLogic: XQuery: Typeswitching based on input "t...
- ▼ June (8)
- ► 2009 (37)
- ► 2008 (24)