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: Tim Mooney <mooney@dogbert.cc.ndsu.NoDak.edu>
Date: Mon, 11 Oct 2004 16:49:39 -0500 (CDT)
To: www-xsl-fo@w3.org
Message-ID: <Pine.OSF.4.60.0410111636320.421768@dogbert.cc.ndsu.NoDak.edu>

In regard to: Re: node after current node in xsl:for-each with xsl:sort...:

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

Sorry about that.  You're right, my question (now) is really about XSLT and
is independent of FO.

>                 <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.

Thanks for explaining.  That makes things a bit clearer.

> 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.

I'm somewhat relieved to hear that what I'm trying to do is "a bit
tricky", as it wasn't at all obvious to me how to proceed.  I have 20+
years of experience programming in procedural languages and certainly
understand things like recursion and iteration, but sometimes it feels
like those years of procedural experience are more a hindrance than a
help, at least as far as XSLT.  ;-)

> 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:-)

I've been using xsltproc from libxslt 1.1.5, but that's only because it's
installed on my workstation and has a good reputation.

Searching on the libxslt site, it appears to have at least some support
for the EXSLT extenions, including exsl:node-set.  I'll see how far I
can get with the excellent tips you've provided.

Thanks much!

Tim Mooney                              mooney@dogbert.cc.ndsu.NoDak.edu
Information Technology Services         (701) 231-1076 (Voice)
Room 242-J6, IACC Building              (701) 231-8541 (Fax)
North Dakota State University, Fargo, ND 58105-5164
Received on Monday, 11 October 2004 21:49:43 UTC

This archive was generated by hypermail 2.3.1 : Tuesday, 6 January 2015 20:58:29 UTC