xsl-list
[Top] [All Lists]

Re: return something x number of times

2005-09-15 13:01:06
On 9/16/05, Jesper Tverskov <jesper(_at_)tverskov(_dot_)dk> 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.

--~------------------------------------------------------------------
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>