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

Re: alphabetic set of xsl:result-document

Subject: Re: alphabetic set of xsl:result-document
From: James Cummings <cummings.james@xxxxxxxxx>
Date: Mon, 22 Aug 2005 15:54:07 +0100
lower case xsl
On 8/22/05, David Carlisle <davidc@xxxxxxxxx> 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[@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[@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

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.