Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
|
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 software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old January 2nd, 2004, 11:40 AM
Friend of Wrox
 
Join Date: Jun 2003
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
 
Old January 5th, 2004, 02:54 PM
Friend of Wrox
 
Join Date: Jun 2003
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>





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





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.