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 December 21st, 2011, 04:24 PM
Registered User
 
Join Date: Aug 2011
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Question range expressions in xslt 2.0

Given the following xml:

Code:
<page pagenumber="1" />
<page pagenumber="2"/>
<page pagenumber="3"/>
<page pagenumber="4"/>
<page pagenumber="7"/>
<page pagenumber="8"/>	
<page pagenumber="9"/>
<page pagenumber="10"/>
how can I capture this as two groups of adjacent pages (i.e. 1-4 and 7-10)? Thank you!
 
Old December 22nd, 2011, 02:40 PM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

There' a neat trick for this invented by David Carlisle:

Code:
<xsl:for-each-group select="page" group-adjacent="@pagenumber - position()">
__________________
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
Regular Expressions XSLT 2.0 stolte XSLT 3 May 22nd, 2007 02:43 PM
Do I need regular expressions..? ypomonh XSLT 2 May 20th, 2007 05:09 PM
Regular Expressions The_Iceman ASP.NET 2.0 Basics 0 September 29th, 2006 05:06 AM
SQL Expressions shazia1 Crystal Reports 0 June 15th, 2006 05:20 AM
XSLT and SELECT with a specfic date range pallone XSLT 15 May 8th, 2006 12:41 PM





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