Subject: Re: [xsl] xsl:for or xsl:repeat From: David Carlisle <davidc@xxxxxxxxx> Date: Wed, 24 May 2006 23:54:41 +0100 |
> Just a quick, somewhat stupid question that probably won't come up in > any real practicality. What if there is the need to iterate more than > there are nodes in the document? well for any fixed number you can ensure that the document you use for the iteration (which doesn't have to be your source document) has enough nodes: for example you can use the stylesheet document('')//node() and have as many nodes as you want in that (add 1000 empty comments at the end if need be) if you are picking up a number dynamically it's probably easier to just give in and write the recursive template (which after all is only 4 or 5 lines of code) apart from anything else loading a massive document just tp iterate overthe integers is a bit expensive. But if you really want to use //node() then z=document('')//node()) m=count($z) a=floor($n div $m) b=$n - $a*$m for-each $z[position() <= $a] for-each $z for-each $z[position() <= $b] will do any number of iterations up to the square of the number of nodes in the stylesheet which can be a pretty big number. (I may have got the sums wrong but too late to think about that too hard) David ________________________________________________________________________ This e-mail has been scanned for all viruses by Star. The service is powered by MessageLabs. For more information on a proactive anti-virus service working around the clock, around the globe, visit: http://www.star.net.uk ________________________________________________________________________
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] xsl:for or xsl:repeat, Wendell Piez | Thread | Re: [xsl] xsl:for or xsl:repeat, Dimitre Novatchev |
Re: [xsl] xsl:for or xsl:repeat, Wendell Piez | Date | Re: [xsl] xsl:for or xsl:repeat, Dimitre Novatchev |
Month |