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?