xsl-list
[Top] [All Lists]

[xsl] Grouping Titles under Correct Category

2007-05-11 12:37:23
Input XML
----------
<?xml version="1.0" encoding="UTF-8"?>
<rss>
<channel>   
      <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>
----------------

Stylesheet
-----------
<?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"/>
<!--Author: Brent Solly-->
<!--Games -->
<xsl:template name="body" match="/">
    <xsl:choose>
            <xsl:when test="rss/channel/generator =
'Systems'">
   <!-- Lists all categories, but not at top of titles
-->
 <xsl:for-each select="rss/channel/item">
     <xsl:variable name="tracker"
select="position()-1"/>
      <xsl:if test="category != ''">
        <xsl:if test="string-length(category) !=
string-length(following::category)">
           <b><xsl:value-of
select="category"/></b><br/>         
         </xsl:if>
      <xsl:value-of select="//item[$tracker]/title"
disable-output-escaping="yes"/><br/> 
      </xsl:if> 
   </xsl:for-each>
  </xsl:when>
  </xsl:choose>
</xsl:template>
</xsl:stylesheet>
-----------



Desired Output
--------------
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
  
---------------


Output Received
--------------------------
Ogre Battle is sold out
SNES
Final Fantasy 3 Breaks FF2 Record
SNES is the Ultimate System
SEGA Genesis
Sonic The Hedgehog an instant success
------------------------------

Is there anyway to achieve the Desired Output?  I have
seen many hints, but still no luck.

I'm using the Cooktop development environment.  Its a
freeware, and not supported anymore, but still works
nicely.
Processor Version: XSLT Processor VersionVendor:
TransformiixVendor 

version="1.0"


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

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--

<Prev in Thread] Current Thread [Next in Thread>