xsl-list
[Top] [All Lists]

XSL:key and Column grouping

2005-02-01 13:24:33
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


--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--



<Prev in Thread] Current Thread [Next in Thread>