xsl-list
[Top] [All Lists]

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

2011-06-14 19:17:43
On Tue, Jun 14, 2011 at 6:14 PM, Olivier Jeulin
<olivier(_dot_)jeulin(_at_)gmail(_dot_)com> 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 :)

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--

<Prev in Thread] Current Thread [Next in Thread>