[xquery-talk] position() and last()
mrys at microsoft.com
Tue Aug 31 21:37:57 PDT 2004
XQuery does not set the context item.
Position() and last() make the most sense in the context of XPath
You would need to write something like:
let $last := count($items)
for $i at $position in $items
($i, if($position = $last) then () else ",")
> -----Original Message-----
> From: talk-bounces at xquery.com [mailto:talk-bounces at xquery.com] On
> Of R. Mark Volkmann
> Sent: Tuesday, August 31, 2004 8:15 PM
> To: talk at xquery.com
> Subject: [xquery-talk] position() and last()
> I know how to use these functions in XSLT, but I haven't figured out
> use them in XQuery.
> For example, suppose I want to put a comma between items, but not
> last one.
> I could do something like this.
> for $i in $items
> return (
> if (position() = last()) then () else ","
> This doesn't work. What am I doing wrong?
> talk at xquery.com
More information about the talk