Re: [xsl] how find out end position using 'for' loop

Subject: Re: [xsl] how find out end position using 'for' loop
From: Brandon Ibach <brandon.ibach@xxxxxxxxxxxxxxxxxxx>
Date: Tue, 14 Jun 2011 20:17:27 -0400
On Tue, Jun 14, 2011 at 6:14 PM, Olivier Jeulin
<olivier.jeulin@xxxxxxxxx> wrote:
> Hi
> Another (better?) answer:
> <xsl:value-of select="string-join(for $i in $start to $end return
> concat('RefArray[',$i,']'), '+')"/>
>
> string-join() does exactly what you want : add a separator between strings.

Good point.  I was focused a bit too much, perhaps, on the smallest,
most direct change to fix the code, so I didn't consider the more
elegant solution.

Another, basically equivalent solution would be:

<xsl:value-of select="for $i in $start to $end return
concat('RefArray[',$i,']')" separator="+"/>

It's worth noting the basic pattern of the first solution, though, in
that it has the potential for additional flexibility, such as in
formatting an English-language list, where the separator is ", " for
all but the last, which is " and ".

-Brandon :)

Current Thread