[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: Grouping Titles under Correct Category

Subject: RE: Grouping Titles under Correct Category
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Fri, 11 May 2007 21:09:38 +0100
RE:  Grouping Titles under Correct Category
This is a completely standard grouping problem. Grouping is much easier in
XSLT 2.0 using xsl:for-each-group, but if you really need to stick with 1.0,
go to http://www.jenitennison.com/xslt/grouping to learn how to do it.

This code:

string-length(category) != string-length(following::category)

is wildly out.

And why do you want to disable-output-escaping?

Michael Kay
http://www.saxonica.com/
 

> -----Original Message-----
> From: Brent Solly [mailto:free12spir@xxxxxxxxx] 
> Sent: 11 May 2007 20:37
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject:  Grouping Titles under Correct Category
> 
> 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

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2007 All Rights Reserved.