Altova Mailing List Archives

RE: [xsl] Grouping into a table (for vertical alignment)

From: Wendell Piez <wapiez@---------------->
Date: 5/28/2004 7:49:00 AM
Hi Daniel,

At 11:01 PM 5/27/2004, you wrote:
Thanks Wendell... trying to figure it out now :p

>Jeni works through one of these in entry 12 in the FAQ
>page at

Looking at it too, entry 12 actually allows me to handle my problem without
a <xsl:key> ...

That's right: it's the other technique I mentioned: the "forward walk" or 
"tree visitor". The key-based technique is just called "key-based 
positional grouping" (since the nodes are grouped based on their relative 
positions), although I like to call it "levitation".

The trade-off is that walking the tree explicitly makes for more complex 
templates that work in what, to a newbie, is a highly unorthodox way, since 
they use <xsl:apply-templates select="following-sibling::*[1]" 
mode="walk"/> or the like. Using keys is a bit more elegant in the XSLT, 
arguably, but lays the stress on that key declaration, whose XPath (as you 
saw) can be ... "ornate", let's say.

I got a question on entry 17:

> <xsl:apply-templates mode="inGroup"
>   select="following-sibling::*[position() &lt; $vGroupLength]"/>

"vGroupLength" is the number of elements in the group.

How does the "position()" work when used in the above manner,
is it just the "context position" within (1) the node list of only
or (2) a node list of all siblings? I guess the first, but I just want to

You are correct, it's the node list of the following siblings. (The context 
of a predicate is provided by the nodes and node-set the predicate operates 

But you don't actually want this as it groups by a count -- first three 
nodes, next three nodes, next three nodes -- or they could be in twelves or 
nineteens: you get the idea. Whereas you need to group based on what nodes' 
neighbors are (which is why your problem is a bit harder).

I really appreciate all the help I am getting from this list. Thanks all.

Sure. You have a toughie, but it's been done. Digging in the archives for 
"forward walk" or "tree visitor" would be a way to learn more about the 
technique I did *not* explain (but which some say is easier: I dunno, if 
you understand keys I think they're about the same).


Wendell Piez                            mailto:wapiez@xxxxxxxxxxxxxxxx
Mulberry Technologies, Inc.      
17 West Jefferson Street                    Direct Phone: 301/315-9635
Suite 207                                          Phone: 301/315-9631
Rockville, MD  20850                                 Fax: 301/315-8285
  Mulberry Technologies: A Consultancy Specializing in SGML and XML


These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.