RE: [xsl] Building an index in XSL

Subject: RE: [xsl] Building an index in XSL
From: "Devlin, Kurt" <Kurt.Devlin@xxxxxxxxxxxxx>
Date: Wed, 14 Feb 2001 17:31:56 -0600
> I have a partial solution implemented but I can not figure out 
> how to not create the HTML table or grouping if no matches are 
> found.  

Keys will help you a lot. I recently implemented something similar to this
in my project.  I didn't put my solution in <table> format, but that should
be trivial to do.

I hope this will help you out.



<!-- Key for the grouping -->
<xsl:key name="indexindex" match="product"

<!-- Key for the product -->
<xsl:key name="indexreference" match="product" use="@name" />

<xsl:template match="grouping" mode="index" >
	<!-- Table "grouping" heading -->
	<xsl:value-of select="@name" />
	<xsl:for-each select="entry">
		<xsl:call-template name="output-index-by-letter">
			<xsl:with-param name="letter"
select="substring(entry,1,1)" />

<xsl:template name="output-index-by-letter">
	<xsl:param name="letter" select="'1'" />
	<xsl:for-each select="key('indexindex',$letter)">
		<xsl:sort select="@name" />
		<!-- If this is the first entry, then output the heading -->
		<xsl:if test="position()=1">
			<p class="indexhead"><xsl:value-of select="$letter"
		<!-- If this is the first time the entry appears, then
output it -->
		<xsl:if test="generate-id() =
			<p class="indexentry"><xsl:value-of select="@name"

 XSL-List info and archive:

Current Thread