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

Multi-grouping with keys (back of book index)

Subject: Multi-grouping with keys (back of book index)
From: "philip vallone" <philip.vallone@xxxxxxxxxxx>
Date: Sat, 21 Oct 2006 14:54:27 -0400
back of book index
Hi, I am building a back of the book index using keys and grouping. I am
able to group the <indexterms> to the @name attribute, but I can't figure
out how to group the @name attribute to its respective letter. My desired
output is:

Desired output:

E
E190
-Aircraft Tail
-Landing Gear
Election
-voting

G
GMM
-Aircraft Logbook Entry 
-MX-4 Deffered Items 

S
Smith Airways
-MEL Policy and Revision number




Here is my XML:


<book>
<indexterm name="GMM">Aircraft Logbook Entry</indexterm>
<indexterm name="Smith Airways">MEL Policy and Revision number</indexterm>
<indexterm name="GMM">MX-4 Deffered Items</indexterm>
<indexterm name="E190">Aircraft Tail</indexterm>
<indexterm name="E190">Landing Gear</indexterm>
<indexterm name="Election">Voting</indexterm>
</book>

Here is my XSL 2.0:

<xsl:output method="html"/>
	<xsl:variable name="XML1" select="/"/>
	<xsl:key name="list" match="//indexterm" use="@name"/>
	<xsl:key name="letter" match="//indexterm" use="substring(@name,
1,1)"/>
	<xsl:template match="/">
		<html>
			<head>
				<title>Manual Index</title>
			</head>
			<style type="text/css">
h2 {font-family:verdana,helvetica,sans-serif;font-size:13pt}
li {font-family:verdana,helvetica,sans-serif;font-size:11pt}
</style>
			<body>
				<xsl:for-each select="$XML1">
					<xsl:for-each
select="//indexterm[generate-id(.)=generate-id(key('list', @name))]/@name">
						<xsl:sort/>
						<xsl:variable name="key"
select="translate(substring(.,1,1),
                                  'abcdefghijklmnopqrstuvwxyz', 
                                  'ABCDEFGHIJKLMNOPQRSTUVWXYZ')"/>
						<xsl:value-of
select="$key"/>
						<xsl:for-each
select="//indexterm[generate-id(.)=generate-id(key('list', @name))]/@name">
							<xsl:sort/>
							<xsl:variable
name="get" select="../@name"/>
							<h2>
	
<xsl:value-of select="."/>
							</h2>
							<ul>
	
<xsl:for-each select="key('list', $get)">
	
<xsl:sort/>
									<li>
	
<xsl:value-of select="."/>
	
</li>
	
</xsl:for-each>
							</ul>
						</xsl:for-each>
					</xsl:for-each>
				</xsl:for-each>
			</body>
		</html>
	</xsl:template>



Thanks for the help.

Phil

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.