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. Regards, Kurt --- <!-- Key for the grouping --> <xsl:key name="indexindex" match="product" use="translate(substring(@name,1,1),'abcdefghijklmnopqrstuvwxyz','ABCDEFGHIJ KLMNOPQRSTUVWXYZ')" /> <!-- 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:call-template> </xsl:for-each> </xsl:template> <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" /></p> </xsl:if> <!-- If this is the first time the entry appears, then output it --> <xsl:if test="generate-id() = generate-id(key('indexreference',@name)[1])"> <p class="indexentry"><xsl:value-of select="@name" /></p> </xsl:if> </xsl:for-each> </xsl:template> XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] Building an index in XSL, Michael Kay | Thread | [Fwd: Re: [xsl] XSLT 1.1 comments (, Uche Ogbuji |
[xsl] [ANN] More Info on eXcelon Po, Christopher Parkerso | Date | RE: [xsl] Saxon Quirk, Eric Vermetten |
Month |