On 8/22/05, David Carlisle <davidc(_at_)nag(_dot_)co(_dot_)uk> wrote:
You probably don't need both the key (the xslt1 way of grouping) and
for-each-group.
after
<xsl:for-each-group select="//div[(_at_)type='psalm']//w"
group-by="lower-case(.)">
select="key('word', lower-case(.)"
is probably the same thing as
select="current-group()"
so you are probably making saxon index everything twice.
If I understand you correctly you just need to insert an extra layer of
grouping, just grouping on the first letter:
<xsl:for-each-group select="//div[(_at_)type='psalm']//w"
group-by="lower-case(substring(.,1,1)">
<xsl:result-file....
<xsl:for-each-group select="current-group()" group-by="lower-case(.)">
<xsl:sort select="lower-case(.)" />
Ok, my brain just isn't working today... Let's expand this. Say I
have an xml snippet of:
------
<div>
<p id="p1">
<w>This</w> <w>is</w> <w>a</w> <w>test</w>, <w>only</w> <w>a</w> <w>test</w>.
<w>This</w> <w>is</w> <w>a</w> <w>test</w>, <w>only</w> <w>a</w> <w>test</w>.
</p>
<p id="p2">
<w>This</w> <w>is</w> <w>a</w> <w>test</w>, <w>only</w> <w>a</w> <w>test</w>.
<w>This</w> <w>Is</w> <w>a</w> <w>boring</w> <w>test</w>, <w>only</w>
<w>a</w> <w>test</w>.
<w>This</w> <w>is</w> <w>a</w> <w>simplified</w> <w>Test</w>,
<w>only</w> <w>a</w> <w>test</w>.
</p>
</div>
-----
If I abandon key() but still want to produce an word index broken down
by alphabetic letter, are you saying I should do something along the
(currently-broken) lines of:
-----
<xsl:template match="/">
<xsl:for-each-group select="//w" group-by="lower-case(.)">
<xsl:sort select="lower-case(.)"/>
<xsl:variable name="pID" select="ancestor::p/@id"/>
<xsl:for-each-group select="lower-case(.)"
group-by="lower-case(substring(.,1,1))">
<xsl:sort select="lower-case(substring(.,1,1))"/>
<xsl:result-document href="FILE-{lower-case(substring(.,1,1))}.html">
<html>
<body>
<h1>Ouput for <xsl:value-of select="substring(lower-case(.),1,1)" /></h1>
<div>
<xsl:for-each-group select="current-group()" group-by="lower-case(.)">
<a
href="htmlversion.html#{$pID}"><xsl:value-of select="current-group()" /></a>
</xsl:for-each-group>
</div>
</body>
</html>
</xsl:result-document>
</xsl:for-each-group>
</xsl:for-each-group>
</xsl:template>
-----
This of course, doesn't work, because it is trying to write multiple
output to the same URI. As you know, this grouping stuff has always
confused me. :-( The actual xslt I've been hacking has an x:replace()
function replacing certain characters (u/v i/y thorn/th) for
comparison purchases based on a previous answer you once gave me ;-)
best,
-James
--
James Cummings, Cummings dot James at GMail dot com
--~------------------------------------------------------------------
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>
--~--