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

Re: Complicated grouping and column question

Subject: Re: Complicated grouping and column question
From: David Carlisle <davidc@xxxxxxxxx>
Date: Wed, 29 Jun 2005 22:40:39 +0100
ul li descendent sibling
                    <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
________________________________________________________________________

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.