[xquery-talk] position() and last()
mrys at microsoft.com
Tue Aug 31 22:02:44 PDT 2004
Let me clarify: XQuery's FOR does not set the context item (obviously,
the XPath expressions do).
> -----Original Message-----
> From: talk-bounces at xquery.com [mailto:talk-bounces at xquery.com] On
> Of Michael Rys
> Sent: Tuesday, August 31, 2004 8:38 PM
> To: R. Mark Volkmann; talk at xquery.com
> Subject: RE: [xquery-talk] position() and last()
> 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
> > to
> > use them in XQuery.
> > For example, suppose I want to put a comma between items, but not
> > 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?
> > _______________________________________________
> > talk at xquery.com
> > http://xquery.com/mailman/listinfo/talk
> talk at xquery.com
More information about the talk