RE: [xsl] Multi-grouping with keys (back of book index)

Subject: RE: [xsl] Multi-grouping with keys (back of book index)
From: "philip vallone" <philip.vallone@xxxxxxxxxxx>
Date: Sat, 21 Oct 2006 16:05:53 -0400
Thanks for the help. This works great in 2.0. I was originally using the
Muenchian method because I was using MSXML with Internet Explorer to
process. This is much easier.

Here is what I used to output to HTML:

Once again...Thanks


	<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-group
select="//indexterm" group-by="substring(@name,1,1)">
						<xsl:sort select="@name"/>
						<h1>
							<xsl:value-of
select="current-grouping-key()"/>
						</h1>
						<xsl:for-each-group
select="current-group()" group-by="@name">
							<span
style="color:blue;">

<xsl:value-of select="current-grouping-key()"/>
							</span>
							<xsl:for-each
select="current-group()">
								<xsl:sort
select="."/>
								<ul>

<span style="font-size:x-small;">

<xsl:value-of select="."/>

</span>
								</ul>
							</xsl:for-each>
						</xsl:for-each-group>
					</xsl:for-each-group>
				</xsl:for-each>
			</body>
		</html>
	</xsl:template>



-----Original Message-----
From: G. Ken Holman [mailto:gkholman@xxxxxxxxxxxxxxxxxxxx]
Sent: Saturday, October 21, 2006 3:08 PM
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject: Re: [xsl] Multi-grouping with keys (back of book index)


As I see it you are using XSLT 1 techniques in an
XSLT 2 stylesheet when XSLT 2 already gives you
what you need as native constructs.

I hope the following use of XSLT 2 facilities helps.

. . . . . . . . . Ken

T:\ftemp>type philip.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>

T:\ftemp>type philip.xsl
<?xml version="1.0" encoding="US-ASCII"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
                 version="2.0">

<xsl:output method="text"/>

<xsl:template match="/">
   <xsl:for-each-group select="/*/indexterm"
group-by="substring(@name,1,1)">
     <xsl:sort select="@name"/>
     <xsl:text>
</xsl:text>
     <xsl:value-of select="current-grouping-key()"/>
     <xsl:text>
</xsl:text>
     <xsl:for-each-group select="current-group()" group-by="@name">
       <xsl:value-of select="current-grouping-key()"/>
       <xsl:text>
</xsl:text>
       <xsl:for-each select="current-group()">
         <xsl:sort select="."/>
         <xsl:text/> - <xsl:value-of select="."/><xsl:text>
</xsl:text>
       </xsl:for-each>
     </xsl:for-each-group>
   </xsl:for-each-group>
</xsl:template>

</xsl:stylesheet>
T:\ftemp>xslt2 philip.xml philip.xsl con

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

T:\ftemp>

--
UBL/XSLT/XSL-FO training: Allerxd/Verx Denmark 2006-11-13,17,20/24
UBL International 2006  2006-11-13/17 http://www.ublconference.com
World-wide corporate, govt. & user group UBL, XSL, & XML training.
G. Ken Holman                 mailto:gkholman@xxxxxxxxxxxxxxxxxxxx
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

Current Thread