Excellent! That's exactly what I was trying to achieve. Thanks.
It also seems that this may have answered my other question: about
saving the list of letters so I can iterate over them later (to make
links to the TOC entries. It looks like I can just take the main
for-each loop and save that code to a variable. I'll play with it.
I guess I need to play with the <xsl:key/>'s some more. The code does
not seem obvious to me at all....
Thanks again...
- Kevin Grover
On 3/3/07, G. Ken Holman <gkholman(_at_)cranesoftwrights(_dot_)com> wrote:
At 2007-03-03 18:52 -0800, Kevin Grover wrote:
>Perfect. Thanks. Just out of curiosity, is this possible
>(practical?) in XSLT 1.0?
I hope this helps.
. . . . . . . Ken
t:\>type grover.xml
<booklist>
<author>
<name file-as="Adams, Douglas">Douglas Adams</name>
</author>
<author>
<name file-as="Anderson, Kevin J.">Kevin J. Anderson</name>
</author>
<author>
<name file-as="Anthony, Piers">Piers Anthony</name>
</author>
<author>
<name file-as="Archer, Jeffrey">Jeffrey Archer</name>
</author>
<author>
<name file-as="Baldacci, David">David Baldacci</name>
</author>
<author>
<name file-as="Ball, Margaret">Margaret Ball</name>
</author>
<author>
<name file-as="Bradley, Marion Zimmer">Marion Zimmer Bradley</name>
</author>
<author>
<name file-as="Carcaterra, Lorenzo">Lorenzo Carcaterra</name>
</author>
<author>
<name file-as="Card, Orson Scott">Orson Scott Card</name>
</author>
<author>
<name file-as="Chalker, Jack L.">Jack L. Chalker</name>
</author>
<author>
<name file-as="Dahl, Roald">Roald Dahl</name>
</author>
<author>
<name file-as="Daley, Brian">Brian Daley</name>
</author>
<author>
<name file-as="Dann, Jack">Jack Dann</name>
</author>
</booklist>
t:\>type grover.xsl
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output method="text"/>
<xsl:key name="alet" match="author"
use="substring(name/@file-as,1,1)"/>
<xsl:template match="/">
<xsl:for-each select="*/author[generate-id(.)=
generate-id(key('alet',substring(name/@file-as,1,1))[1])]">
<xsl:text>

</xsl:text>
<xsl:value-of select="substring(name/@file-as,1,1)"/>
<xsl:text>
</xsl:text>
<xsl:for-each select="key('alet',substring(name/@file-as,1,1))">
<xsl:value-of select="name/@file-as"/>
<xsl:text>
</xsl:text>
</xsl:for-each>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
t:\>call xslt grover.xml grover.xsl grover.out
t:\>type grover.out
A
Adams, Douglas
Anderson, Kevin J.
Anthony, Piers
Archer, Jeffrey
B
Baldacci, David
Ball, Margaret
Bradley, Marion Zimmer
C
Carcaterra, Lorenzo
Card, Orson Scott
Chalker, Jack L.
D
Dahl, Roald
Daley, Brian
Dann, Jack
t:\>rem Done!
--
World-wide corporate, govt. & user group XML, XSL and UBL training
RSS feeds: publicly-available developer resources and training
G. Ken Holman mailto:gkholman(_at_)CraneSoftwrights(_dot_)com
Crane Softwrights Ltd. http://www.CraneSoftwrights.com/s/
Box 266, Kars, Ontario CANADA K0A-2E0 +1(613)489-0999 (F:-0995)
Male Cancer Awareness Aug'05 http://www.CraneSoftwrights.com/s/bc
Legal business disclaimers: http://www.CraneSoftwrights.com/legal
--~------------------------------------------------------------------
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>
--~--
--~------------------------------------------------------------------
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>
--~--