W3C home > Mailing lists > Public > www-xsl-fo@w3.org > October 2004

Re: node after current node in xsl:for-each with xsl:sort (was: conditional page-break table based on row number?)

From: David Carlisle <davidc@nag.co.uk>
Date: Mon, 11 Oct 2004 22:23:40 +0100
Message-Id: <200410112123.WAA32609@penguin.nag.co.uk>
To: mooney@dogbert.cc.ndsu.NoDak.edu
CC: www-xsl-fo@w3.org


this list is more for FO issues than XSLT programming (I think) but
anyway

                 <xsl:apply-templates
                             select="self::*[position() + 1]"
self::* selects at most 1 node, which will always have position()=1
but in any case, if you use [] with a numeric value rather than a
predicate it is short for
[position()=...]
so *[1] means *[position()=1]
and selects the first thing and
[position() + 1] is short for [position()=(position() + 1)] and selects
all those elements for which 0=1 ie, it selects the empty set.


Actually it's a bit tricky in pure xslt 1 to sort and then access the
sorted list at the same time, as the sorted list information goes to the
result tree where by design you can't really get it back.

If you can use your processor's node-set extension (if it has one) first
sort the input into a temporary variable then process every other item
in this sorted list, and access the next item by
following-sibling::*[1]
if xx:node-set() isn't available, ask again:-)

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
________________________________________________________________________
Received on Monday, 11 October 2004 21:24:03 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Wednesday, 3 October 2007 16:06:13 GMT