[xsl] XSL:key and Column grouping

Subject: [xsl] XSL:key and Column grouping
From: David Laurie <dlaurie@xxxxxxxxxxx>
Date: Tue, 1 Feb 2005 13:24:33 -0700
Hello all,

I have a problem with a stylesheet that groups a set of elements into three 
columns. As it is not flat, I have attempted to use an xsl:key function to 
pick out every 3rd element out of all the desired nodes. This works, but when 
I then use xsl:apply-templates to specify the output of those nodes and their 
next two siblings, the nodes returned revert to their position in the normal 
flow of the document. I have only recently started using xsl:key so it may be 
that this is a simple problem or that I don't know the proper syntax (both 
likely)). What I need is a way to access the key function at the 
apply-templates step; or conversely to specify groups of three nodes when I 
call the key function. I have tried both without success. Any ideas?

The xsl I am using (with xalan):
<xsl:key name="map" match="mapunits/maps" use="."/>
<xsl:template match="chapters" mode="track-thumb">
	<xsl:if test="@chap=$chapter">
		<div style="margin-top: 30px; margin-bottom: 20px;">
		<span class="trackNumber">Track <xsl:value-of select="$chapter"/> - </span>
		<span class="trackTitle">
			<xsl:value-of select="chaptertitle"/> Maps</span>
		<table border="0" cellpadding="0" cellspacing="0" >
			<xsl:for-each select="key('map', mapunits/maps)[position() mod 3 = 1]">

			<tr valign="top" style="width:100%">
				<xsl:apply-templates select=".|following-sibling::maps[position() &lt; 




David Laurie
MA Humanities Computing

Current Thread