|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] RE: Building an index in XSL
> 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
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|

Cart








