[xquery-talk] position() and last()
Jason Hunter
jhunter at xquery.com
Tue Aug 31 22:52:40 PDT 2004
R. Mark Volkmann wrote:
> I know how to use these functions in XSLT, but I haven't figured out how to
> use them in XQuery.
> For example, suppose I want to put a comma between items, but not after the
> last one.
> I could do something like this.
>
> for $i in $items
> return (
> $i,
> if (position() = last()) then () else ","
> )
>
> This doesn't work. What am I doing wrong?
You can also try this:
string-join($items, ",")
...although you're probably first going to have to convert the item
sequence to a string sequence in a manner like this:
string-join(for $i in $items return string($i), ",")
-jh-
More information about the talk
mailing list