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 May 23rd, 2008, 09:11 PM
Authorized User
 
Join Date: Jan 2008
Posts: 16
Thanks: 0
Thanked 0 Times in 0 Posts
Default How to loop through a range?

I'm trying to loop through a range in a node set, but I can't get it to work. This is what I have so far, I'm not sure what else to try... Thanks

Code:
<xsl:variable name="Items" select="//Item" />

// Start at 4 and stop at 6  (These are ten items in the set)
<xsl:for-each select="$Items[position()>3 and $Items[position()<=6]">
 
Old May 24th, 2008, 03:46 AM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

Your code looks fine except that of course "<" needs to be escaped as "&lt;".

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
 
Old May 24th, 2008, 03:48 AM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

Sorry, just looked at it more carefully - the brackets don't match so of course it's not fine. Should be

select="$Items[position()>3 and position()&lt;=6]"

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
 
Old May 24th, 2008, 03:50 PM
Authorized User
 
Join Date: Jan 2008
Posts: 16
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks, that worked perfectly!






Similar Threads
Thread Thread Starter Forum Replies Last Post
Randomize a range frankjuel Excel VBA 5 February 24th, 2016 10:26 AM
Date Range Flipflop SQL Language 6 November 25th, 2005 08:36 AM
Help with Date Range PacMed Access 1 February 1st, 2005 12:30 PM
nested while loop doesn't loop hosefo81 PHP Databases 5 November 12th, 2003 08:46 AM





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