[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: return something x number of times

Subject: Re: return something x number of times
From: Dimitre Novatchev <dnovatchev@xxxxxxxxx>
Date: Fri, 16 Sep 2005 06:01:06 +1000
xslt for each x times
On 9/16/05, Jesper Tverskov <jesper@xxxxxxxxxxx> wrote:
> Hi list
>
> In XSLT 2.0 (in XMLSpy) this markup:
> <xsl:variable name="indent_4" select="for $a in 1 to 4 return 'x'"/>
>
> Returns 'x x x x'.
>
> Why the whitespace?
>
> How can I get 'xxxx' returned both in XSLT 1.0 and in XSLT 2.0?

In XSLT 2.0 only one can use:

   <xsl:sequence select="string-join(for $a in 1 to 4 return 'x', '')"/>


The following code works both in XSLT 1.0 and XSLT 2.0:

   <xsl:for-each select=
      "(document('')//node() | document('')//namespace::*)[position() &lt;=
4]">
     <xsl:value-of select="'x'"/>
   </xsl:for-each>

For any non-trivial application of this problem (where the number of
repetitions N is unknown or has a very big value) one can use
recursion explicitly or it is even more appropriate to use an FXSL
function such as f:iter()


--
Cheers,
Dimitre Novatchev
---------------------------------------
Getting caught is the mother of invention.

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.