[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

XSL:key and Column grouping

Subject: XSL:key and Column grouping
From: David Laurie <dlaurie@xxxxxxxxxxx>
Date: Tue, 1 Feb 2005 13:24:33 -0700
column grouping
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>
		</div>
		<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; 
3]"/>

			</tr>

			</xsl:for-each>
		</table>
	</xsl:if>
</xsl:template>

Cheers,
dave

David Laurie
MA Humanities Computing

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.