Subject: Re: [xsl] return something x number of times From: Dimitre Novatchev <dnovatchev@xxxxxxxxx> Date: Fri, 16 Sep 2005 06:01:06 +1000 |
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.
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] return something x number of , Jesper Tverskov | Thread | RE: [xsl] return something x number, Michael Kay |
Re: [xsl] jd.xslt dead?, Tony Lavinio | Date | Re: [xsl] attribute test, Spencer Tickner |
Month |