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() < 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>