Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
|
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old November 8th, 2011, 01:50 PM
Registered User
 
Join Date: Nov 2011
Posts: 12
Thanks: 1
Thanked 0 Times in 0 Posts
Default Looping between the numbers using Xsl:for each?

Hi,

I am trying to loop between two numbers say <Xsl:for each select="10 to 20"> in XSL1.0.

But, i am getting an exception "Expected end of the expression "to"".

I did some search and found that this feature is available in XSL2.0 version.

Is there any other way where i can loop two numbers using <Xsl:for each> in 1.0?
 
Old November 8th, 2011, 06:00 PM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

There are two techniques in use.

(a) provided there are sufficiently many nodes in your document, you can do

[code]
<xsl:for-each select="//node()[position() &lt; $end - $start]">
<xsl:variable name="this" select="position() + $start - 1"/>
...
</xsl:for-each>

(b) use recursion. Call a template passing $start as a parameter; make it call itself passing $start + 1; terminate the recursion when $start reaches $end.
__________________
Michael Kay
http://www.saxonica.com/
Author, XSLT 2.0 and XPath 2.0 Programmer\'s Reference





Similar Threads
Thread Thread Starter Forum Replies Last Post
xsl:Looping more than one time through same node maryj XSLT 36 April 30th, 2009 01:01 AM
looping in XSL itsmaheshp XSLT 3 February 24th, 2009 10:47 AM
Plz help: looping variable in xsl priyatowin XSLT 1 September 11th, 2006 05:38 AM
adding up 2 numbers in xsl umair.aziz XSLT 3 July 14th, 2006 09:24 AM
regarding adding numbers in xsl umair.aziz XSLT 1 June 24th, 2006 12:12 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.