[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: return something x number of 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() <= 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.
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|