Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > XML > XSLT
Password Reminder
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 March 11th, 2006, 10:21 AM
Registered User
 
Join Date: Mar 2006
Location: , , .
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Showing 5 latest additions, problem with sorting

hello
i have a xml file with all my dvd movies in it, generated by a vb.net application. Im using xsl transformation on the xml file to show the list in a table and alternating colors.

That all works fine, but i also want to show the 5 latest additions on my xml file. When im doing a for loop from 1 to 6 it shows me the first 5 additions, so i tried to put that for loop in a for each loop with a descending sort, but this doesnt work

problem is that i want to show the complete dvd list first sorted by title and then showing the 5 latest additions. So i need to find a way to sort that whole list again by position[] and descending so i can apply my for loop from 1 to 5.

Does anyone know how i could do that?

this is my XSL file

u can find my xml file here http://www.grasjap.be/dvd.xml
and this is the xsl file i use:

currently its just showing the 5 first additions which needs to become the 5 last

Code:
<?xml version="1.0" encoding="ISO-8859-1"?>

<!-- xsl linken aan de xml file 
<?xml-stylesheet type="text/xsl" href="dvd.xsl"?>
-->

<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method='html' version='1.0' encoding='UTF-8' indent='yes'/>

<xsl:template match="/">
  <html>
  <body style="background-color:#333333; vertical-align:middle">
  <h3 style="color:#FFFFFF; font-family:Verdana, Arial, Helvetica, sans-serif">Mijn DVD Collectie</h3>
  <br />







<h3 style="color:#FFFFFF; font-family:Verdana, Arial, Helvetica, sans-serif">Aantal Films In Database: <xsl:value-of select="count(DVDLijst/DVD)"/></h3>
<br />









<h3 style="color:#FFFFFF; font-family:Verdana, Arial, Helvetica, sans-serif">Alle Films:</h3>    

      <table style="border:none">
      <tr style="background-color:#666666; font-size:18px; color:#FFFFFF; font-weight:bold; font-family:Verdana, Arial, Helvetica, sans-serif">
        <th>Titel</th>
        <th>Jaar</th>
    <th>Genre</th>
        <th>Land</th>
        <th>Regisseur</th>
    <th>Discs</th>
    <th>Boxset</th>
      </tr>











      <xsl:for-each select="DVDLijst/DVD">
    <xsl:sort select="Titel"/>
    <xsl:choose>
        <xsl:when test="position() mod 2 = 0">
      <tr style="background-color:#666666; font-size:14px; color:#FFFFFF; font-weight:bold; font-family:Verdana, Arial, Helvetica, sans-serif">
         <td><xsl:value-of select="Titel"/></td>
        <td><xsl:value-of select="Jaar"/></td>
    <td><xsl:value-of select="Genre"/></td>
        <td><xsl:value-of select="Land"/></td>
        <td><xsl:value-of select="Regisseur"/></td>
    <td><xsl:value-of select="Discs"/></td>
    <td><xsl:value-of select="Boxset"/></td>
      </tr>
      </xsl:when>
        <xsl:otherwise>
        <tr style="background-color:#CCCCCC; font-size:14px;color:#000000; font-weight:bold; font-family:Verdana, Arial, Helvetica, sans-serif">
        <td><xsl:value-of select="Titel"/></td>
        <td><xsl:value-of select="Jaar"/></td>
    <td><xsl:value-of select="Genre"/></td>
        <td><xsl:value-of select="Land"/></td>
        <td><xsl:value-of select="Regisseur"/></td>
    <td><xsl:value-of select="Discs"/></td>
    <td><xsl:value-of select="Boxset"/></td>
      </tr>
        </xsl:otherwise>
    </xsl:choose>
      </xsl:for-each>
    </table>













<br />
<h3 style="color:#FFFFFF; font-family:Verdana, Arial, Helvetica, sans-serif">Laatste 5 Toevoegingen:</h3>
<table style="border:none">

      <tr style="background-color:#666666; font-size:18px; color:#FFFFFF; font-weight:bold; font-family:Verdana, Arial, Helvetica, sans-serif">
        <th>Titel</th>
        <th>Jaar</th>
    <th>Genre</th>
        <th>Land</th>
        <th>Regisseur</th>
    <th>Discs</th>
    <th>Boxset</th>
      </tr>

    <xsl:for-each select="DVDLijst/DVD [position() &lt; 6]">
    <xsl:choose>
        <xsl:when test="position() mod 2 = 0">
      <tr style="background-color:#666666; font-size:14px; color:#FFFFFF; font-weight:bold; font-family:Verdana, Arial, Helvetica, sans-serif">
         <td><xsl:value-of select="Titel"/></td>
        <td><xsl:value-of select="Jaar"/></td>
    <td><xsl:value-of select="Genre"/></td>
        <td><xsl:value-of select="Land"/></td>
        <td><xsl:value-of select="Regisseur"/></td>
    <td><xsl:value-of select="Discs"/></td>
    <td><xsl:value-of select="Boxset"/></td>
      </tr>
      </xsl:when>
        <xsl:otherwise>
        <tr style="background-color:#CCCCCC; font-size:14px;color:#000000; font-weight:bold; font-family:Verdana, Arial, Helvetica, sans-serif">
        <td><xsl:value-of select="Titel"/></td>
        <td><xsl:value-of select="Jaar"/></td>
    <td><xsl:value-of select="Genre"/></td>
        <td><xsl:value-of select="Land"/></td>
        <td><xsl:value-of select="Regisseur"/></td>
    <td><xsl:value-of select="Discs"/></td>
    <td><xsl:value-of select="Boxset"/></td>
      </tr>
        </xsl:otherwise>
    </xsl:choose>
      </xsl:for-each>
      </table>




  </body>
  </html>
</xsl:template>
</xsl:stylesheet>
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
MDI Child Form Problem (not showing) panuvin C# 9 March 22nd, 2013 12:49 PM
No additions using VBA and SQL Bob Pierce Access VBA 1 February 6th, 2007 01:20 PM
Form Showing Reports Problem Brendan Bartley Access 2 December 7th, 2006 02:08 PM
textboxes and additions toiletgraffiti C# 4 January 23rd, 2006 11:50 AM
Access 2000 "Open ODBC SQL Table for Additions" cjdphlx Access VBA 3 July 18th, 2005 02:05 PM



All times are GMT -4. The time now is 03:07 AM.


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