SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    Talk to the /dev/null Theiggsta's Avatar
    Join Date
    Mar 2001
    Location
    Tampa, FL
    Posts
    376
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Very advanced XSL...

    Hey there, I am trying to do something rather complex in XSL...

    I am trying to display news on a page, but have it sorted and grouped by day. Meaning that all news for a given date is under the header of the day and so on, ill give an example below so you know what I mean...

    Monday June 23, 2003

    News goes here, was posted on monday...
    (posted Sunday June 23rd, 2003)

    News goes here, was posted on monday...
    (posted Sunday June 23rd, 2003)

    News goes here, was posted on monday...
    (posted Sunday June 23rd, 2003)

    Sunday June 22, 2003

    News goes here, was posted on sunday...
    (posted Sunday June 22nd, 2003)

    News goes here, was posted on sunday...
    (posted Sunday June 22nd, 2003)

    News goes here, was posted on sunday...
    (posted Sunday June 22nd, 2003)

    For the test of this I am using slashdots XML:RSS feed (from an early morning hour) and so far has tried using a xsl:sort technique to get it sorted first, however grouping it is where I am trying to figure this whole thing out. How exactly can I group nodes based on a value already sorted?
    Aaron "Theiggsta" Kalin
    Pixel Martini
    Ruby and Rails Developer

  2. #2
    Back in Action Winged Spider's Avatar
    Join Date
    Jun 2001
    Location
    outside my mind
    Posts
    900
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ill need to see the XML before I can write you some code but I think it will go something like this.

    Code:
    <xsl:variable name="news-date"
                      select="/news
                    /newsdate[not(@date=preceding-sibling::news/@newsdate)]
    @newsdate
    />
    This code is directly from a book in my lap with the variables changed, and it has a lot more too it that you can change.

    Also this code assumes that the news date is stored in a attribute instead of a element. I don't know how things would change if it wasn't.

    Keep this thread going please, I want to work with you on this. I've just jumped into the deep and of XML and XSLT and need to get experience. I have to do the same thing based on catagories instead of dates.

  3. #3
    Talk to the /dev/null Theiggsta's Avatar
    Join Date
    Mar 2001
    Location
    Tampa, FL
    Posts
    376
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Well I went and copied slashdot's RSS feed to try this out on first... if it works there, itll definately work for me...

    HTML Code:
    <?xml version="1.0" encoding="ISO-8859-1"?>
    <?xml-stylesheet type="text/xsl" href="test.xsl" ?>
    <backslash>
    	<story>
    		<title>nForce2 GART Driver Finally Released For Linux</title>
    		<url>http://slashdot.org/article.pl?sid=03/06/22/0342259</url>
    		<time>2003-06-22 07:52:11</time>
    		<author>timothy</author>
    
    		<department>expanding-choices</department>
    		<topic>137</topic>
    		<comments>66</comments>
    		<section>articles</section>
    		<image>topichardware.gif</image>
    	</story>
    
    	<story>
    		<title>How Labels And Artists Divvy Up Your Dollar Online</title>
    		<url>http://slashdot.org/article.pl?sid=03/06/22/0323239</url>
    		<time>2003-06-22 04:26:15</time>
    		<author>timothy</author>
    		<department>heads-i-win-tails-you-guessed-it</department>
    
    		<topic>141</topic>
    		<comments>315</comments>
    		<section>articles</section>
    		<image>topicmusic.gif</image>
    	</story>
    	<story>
    		<title>PocketPC 2003 Reviewed</title>
    
    		<url>http://slashdot.org/article.pl?sid=03/06/22/0222237</url>
    		<time>2003-06-22 02:40:27</time>
    		<author>timothy</author>
    		<department>posted-from-a-zaurus</department>
    		<topic>100</topic>
    		<comments>128</comments>
    
    		<section>articles</section>
    		<image>topicpilot.gif</image>
    	</story>
    	<story>
    		<title>Aussie Company Releases Xbox Mod-Chip Designs</title>
    		<url>http://slashdot.org/article.pl?sid=03/06/22/0057216</url>
    		<time>2003-06-22 01:15:49</time>
    
    		<author>timothy</author>
    		<department>like-a-radar-detector-in-virginia</department>
    		<topic>211</topic>
    		<comments>164</comments>
    		<section>games</section>
    
    		<image>topicxbox.gif</image>
    
    	</story>
    	<story>
    		<title>Flight Simulator 2002 With 13 Monitors And 9 PCs</title>
    		<url>http://slashdot.org/article.pl?sid=03/06/21/2231242</url>
    		<time>2003-06-22 00:07:59</time>
    		<author>timothy</author>
    		<department>that's-a-lot-of-lead-and-glass</department>
    
    		<topic>127</topic>
    		<comments>317</comments>
    		<section>articles</section>
    		<image>topicgames.gif</image>
    
    	</story>
    	<story>
    
    		<title>Bill Would Let FBI Police File-Sharing</title>
    		<url>http://slashdot.org/article.pl?sid=03/06/21/2251246</url>
    		<time>2003-06-21 22:59:20</time>
    		<author>timothy</author>
    		<department>what-would-liddy-do</department>
    		<topic>103</topic>
    
    		<comments>345</comments>
    		<section>yro</section>
    		<image>topicus.gif</image>
    	</story>
    	<story>
    		<title>Honeypot For Identifying Email-Harvesters</title>
    		<url>http://slashdot.org/article.pl?sid=03/06/21/2130234</url>
    
    		<time>2003-06-21 21:49:20</time>
    		<author>timothy</author>
    		<department>off-with-their-heads</department>
    		<topic>111</topic>
    		<comments>197</comments>
    		<section>yro</section>
    
    		<image>topicspam.gif</image>
    	</story>
    	<story>
    
    		<title>Website Posts Partial SSNs of Politicians in Protest</title>
    		<url>http://slashdot.org/article.pl?sid=03/06/21/1631238</url>
    		<time>2003-06-21 20:34:44</time>
    
    		<author>CowboyNeal</author>
    		<department>alliteration-never-gets-old</department>
    		<topic>158</topic>
    		<comments>229</comments>
    		<section>yro</section>
    		<image>topicprivacy.gif</image>
    
    	</story>
    	<story>
    		<title>Nimble V5 - The OQO Killer?</title>
    		<url>http://slashdot.org/article.pl?sid=03/06/21/1756226</url>
    		<time>2003-06-21 19:25:47</time>
    		<author>timothy</author>
    		<department>bargain-at-half-the-price</department>
    
    		<topic>137</topic>
    		<comments>114</comments>
    		<section>articles</section>
    		<image>topichardware.gif</image>
    	</story>
    	<story>
    		<title>Managing Bandwidth and Bandwidth Costs?</title>
    
    		<url>http://slashdot.org/article.pl?sid=03/06/19/2239241</url>
    		<time>2003-06-21 18:37:57</time>
    		<author>Cliff</author>
    		<department>preparations-for-a-slashdotting</department>
    		<topic>95</topic>
    		<comments>178</comments>
    
    		<section>askslashdot</section>
    		<image>topicinternet.gif</image>
    	</story>
    </backslash>
    Thanks again for the reply and help, im still trying to figure this one out... I just want to categories all the news by date and list them that way.
    Aaron "Theiggsta" Kalin
    Pixel Martini
    Ruby and Rails Developer

  4. #4
    Talk to the /dev/null Theiggsta's Avatar
    Join Date
    Mar 2001
    Location
    Tampa, FL
    Posts
    376
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Keep in mind the code must not be date specific, it should be able to determine which day is precedent ove ranother and sort as such. I used to do this in a double-set of SQL queries, but since this is XML data, the ballgame has changed.

    This snippet of code might be useful too..
    HTML Code:
    <xsl:sort select="substring(@postDate,3,2)"/> <!-- day   -->
    Aaron "Theiggsta" Kalin
    Pixel Martini
    Ruby and Rails Developer

  5. #5
    Talk to the /dev/null Theiggsta's Avatar
    Join Date
    Mar 2001
    Location
    Tampa, FL
    Posts
    376
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Still can't figure it out...
    Aaron "Theiggsta" Kalin
    Pixel Martini
    Ruby and Rails Developer

  6. #6
    Back in Action Winged Spider's Avatar
    Join Date
    Jun 2001
    Location
    outside my mind
    Posts
    900
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I'm on it kinda, I'm having problems with my XML too. I can't get my categories to group but will post my solution when I get it.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •