Subject: [xsl] Re: Grouping Titles under Correct Categories - Solved! From: Brent Solly <free12spir@xxxxxxxxx> Date: Mon, 14 May 2007 06:46:55 -0700 (PDT) |
<?xml version="1.0" encoding="UTF-8"?> <rss> <channel> <generator>Systems</generator> <item> <title>Ogre Battle is sold out</title> <description>There is a high demand for this rare game.</description> <category>SNES</category> </item> <item> <title>Final Fantasy 3 Breaks FF2 Record</title> <description>It was thought impossible to outdo FF2 gameplay.</description> <category>SNES</category> </item> <item> <title>SNES is the Ultimate System</title> <description>This new system has revolutionized controller design.</description> <category>SNES</category> </item> <item> <title>Sonic The Hedgehog an instant success</title> <description>A new Mario is been born.</description> <category>SEGA Genesis</category> </item> <item> <title>Joe Montanna Talking Football is amazing</title> <description>Listen play by play in this new form of football game.</description> <category>SEGA Genesis</category> </item> </channel> </rss> <?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> <xsl:strip-space elements="*" /> <xsl:output method="html" encoding="UTF-8"/> <xsl:key name="cat_name" match="item" use="category" /> <!--Games --> <xsl:template name="body" match="/"> <xsl:choose> <xsl:when test="rss/channel/generator = 'Systems'"> <!-- Generates Table of Contents with content links --> <xsl:apply-templates/> <br/><br/> <!-- Description --> <xsl:for-each select="rss/channel/item"> <xsl:variable name="link-path" select="link"/> <b class="abbott_hl2"><xsl:value-of select="title"/></b><br/> <xsl:if test="description!=''"> <a name="{generate-id()}"/> <xsl:value-of select="description" /><xsl:text> </xsl:text><a href="{$link-path}" target="_blank" class="abbott_storyurl">Click here for fulltext</a><br/><br/> </xsl:if> </xsl:for-each> <!-- End Description --> </xsl:when> </xsl:choose> </xsl:template> <!--Generates a unique id based on category name--> <xsl:template match="channel"> <xsl:apply-templates select="item[generate-id(.) = generate-id(key('cat_name', category)[1])]" /> </xsl:template> <!--Outputs all titles relating to the category named in each item--> <xsl:template match="rss/channel/item"> <b><xsl:value-of select="category" /></b> <ul> <xsl:for-each select="key('cat_name', category)"> <li> <a href="#{generate-id()}"> <xsl:value-of select="title" /> </a> </li> </xsl:for-each> </ul> </xsl:template> </xsl:stylesheet> Output Now ----------- SNES Ogre Battle is sold out Final Fantasy 3 Breaks FF2 Record SNES is the Ultimate System SEGA Genesis Sonic The Hedgehog an instant success Joe Montanna Talking Football is amazing ----------- I reviewed Jenni's page again , and I got it. Amazing. Thanks alot for your help Micheal. Any state, any entity, any ideology that fails to recognize the worth, the dignity, the rights of man - That state is obsolete. -spooky man from Twilight Zone (1961) http://s8.invisionfree.com/Solo_Tee_and_Company/index.php?act=idx
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] Re: xsl-list Digest 14 May 20, Brent Solly | Thread | [xsl] xsl:key and document() loadin, Dale Tan |
Re: [xsl] Replacing the space chara, Florent Georges | Date | Re: [xsl] Replacing the space chara, Mark Peters |
Month |