Altova Mailing List Archives

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

From: Brandon Ibach <brandon.ibach@---------------.--->
To: xsl-list@-----.------------.---
Date: 6/15/2011 12:18:00 AM
On Tue, Jun 14, 2011 at 6:14 PM, Olivier Jeulin
<olivier.jeulin@g...> 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:
To unsubscribe, go to:
or e-mail: <mailto:xsl-list-unsubscribe@l...>


These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.