xsl-list
[Top] [All Lists]

Re: Complicated grouping and column question

2005-06-29 14:40:39

                    <xsl:apply-templates
select="/schedule/division[substring(@name,1,1) = $current-letter]">


No need to search the entire file again to find these, the divisions
with that letter are the current-group() and have already been collected
up by for-each-group.

I'd do your sorting/grouping first then split in to two later:

<xsl:template name="make-index">
<xsl:variable name="x">
        <ul>
        <xsl:for-each-group select="/schedule/division" 
group-by="substring(@name,1,1)">
            <xsl:sort select="current-grouping-key()" />
            <xsl:variable name="current-letter" select="current-grouping-key()" 
/>
            
            <li>
                <h2><xsl:value-of select="$current-letter" /></h2>
                <ul>
                    <xsl:apply-templates
select="current-group()">
                        <xsl:sort select="@name" />
                    </xsl:apply-templates>
                </ul>
            </li>
        </xsl:for-each-group>
    </ul>
</xsl:variable>
<!-- the number of li's at any level with text as an approximation of line 
counts-->
<xsl:variable name="c" select="count($x//li[text()]) div 2"/> 

<!-- the top level (letter) li that has the half way point -->
<xsl:variable name="letter2"
                select="$x/descendent::li[$c]/ancestor::li[last()]"/>
<!-- copy the half way letter and its older siblings into one td and
the later ones into the second td.
-->
<table>
<tr>
<ul>
<xsl:copy-of select="$letter2|$letter2/preceding-sibling::li"/>
</ul>
<td>
<xsl:copy-of select="$letter2/following-sibling::li"/>
</td>
</ul>
</ul>
</tr>
</table>
</xsl:template>


Untested, but something along those lines...

David

________________________________________________________________________
This e-mail has been scanned for all viruses by Star. The
service is powered by MessageLabs. For more information on a proactive
anti-virus service working around the clock, around the globe, visit:
http://www.star.net.uk
________________________________________________________________________

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