Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > XML > XSLT
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old January 2nd, 2004, 11:40 AM
Friend of Wrox
 
Join Date: Jun 2003
Location: Harrisburg, PA, USA.
Posts: 1,998
Thanks: 0
Thanked 3 Times in 3 Posts
Default Retrieve top 10

Hello,

I want to create a XSLT that only returns the top so many entries of data based on a date. What I want to do is create a top-ten list of most recently modified files in the XML. My XML looks like:

<Documents>
  <Document>
    <Name>Document</Name>
    .
    .
    <LastChangeDate>1/2/2004</LastChangeDate>

Basically, I want to retrieve the last ten documents with the most recent last change date. I have a process defined for modifying the XML with the new last change date; however, I'm not sure how to do this through XSLT.

Any help is appreciated.

Thanks,

Brian Mains
__________________
Brian
Reply With Quote
  #2 (permalink)  
Old January 5th, 2004, 02:54 PM
Friend of Wrox
 
Join Date: Jun 2003
Location: Harrisburg, PA, USA.
Posts: 1,998
Thanks: 0
Thanked 3 Times in 3 Posts
Default

Hey,

For anybody who wanted to know, I figured it out; here are the two templates that are needed:

<xslt:template match="Documents">
  <xslt:apply-templates select="Document">
    <xslt:sort select="LastChangeDate" order="descending"/>
  </xslt:apply-templates>
</xslt:template>

<xslt:template match="Document">
  <xslt:if test="position() &lt;= 10">
    <a>
      <xslt:attribute name="href"><xslt:value-of select="Path"/></xslt:attribute>
      <xslt:value-of select="Name"/>
    </a><br/>
  </xslt:if>
</xslt:template>
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Select .. Top 10 by Month? crabjoe SQL Server 2000 17 March 27th, 2008 11:48 AM
Query to retrieve the first 10 records inserted anup_daware Oracle ASP 0 August 6th, 2007 01:50 AM
Trying to retrieve top 1 for multiple rows MonicaM SQL Language 2 May 16th, 2006 03:29 AM
SELECT TOP n NOT SELECTING TOP n! ibi SQL Language 8 March 30th, 2005 08:08 PM
Crystal reports 10.0 Query about showing top N rec rajdotme Crystal Reports 1 June 12th, 2004 03:35 AM



All times are GMT -4. The time now is 01:28 PM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.