|
next
|
 Subject: Need help with a XSL file Author: Brian B Date: 17 Jun 2007 06:27 PM
|
I received a XSL file from someone on this board about 2 years ago and it works great. I am looking to add another option to it and I need a little help. The XSL file currently sorts by date then limits the results by the max number given then finally sorts by title. What I'm looking to do is have it first grab all the records where the date is equal to or less than todays date then sort by date, max number and title. Here is the script.
<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:msxml="urn:schemas-microsoft-com:xslt">
<xsl:output method="html"/>
<xsl:param name="MaxItems" select="20"/>
<xsl:param name="Columns" select="3"/>
<xsl:template match="/">
<xsl:variable name="ItemsByDate">
<xsl:for-each select="rss">
<xsl:copy>
<xsl:for-each select="item">
<!-- format a string to be used a sorting key: yyyy-mm-dd -->
<xsl:sort order="descending" select="concat( substring(substring-after(date, ', '), 1), '-', format-number(month, '00'), '-', format-number(substring(substring-before(date, ', '), 4,3), '00'))"/>
<xsl:copy-of select="."/>
</xsl:for-each>
</xsl:copy>
</xsl:for-each>
</xsl:variable>
<xsl:variable name="ItemsByDateShort">
<xsl:for-each select="msxml:node-set($ItemsByDate)/rss">
<xsl:copy> <!-- limit to the first MaxItems -->
<xsl:for-each select="item[position() <= $MaxItems]">
<xsl:copy-of select="."/>
</xsl:for-each>
</xsl:copy>
</xsl:for-each>
</xsl:variable>
<xsl:variable name="ItemsByTitleShort">
<xsl:for-each select="msxml:node-set($ItemsByDateShort)/rss">
<xsl:copy>
<xsl:for-each select="item">
<xsl:sort order="ascending" select="title"/>
<xsl:copy-of select="."/>
</xsl:for-each>
</xsl:copy>
</xsl:for-each>
</xsl:variable>
<xsl:apply-templates select="msxml:node-set($ItemsByTitleShort)/rss"/>
</xsl:template>
<xsl:template match="rss">
<xsl:for-each select="item">
<xsl:apply-templates select="."/>
</xsl:for-each>
</xsl:template>
<xsl:template match="item">
<table border="1" cellspacing="0" width="744">
<tr>
<td><xsl:value-of select="title"/></td>
<td width="234"><xsl:value-of select="date"/></td>
</tr>
</table>
</xsl:template>
</xsl:stylesheet>
Thanks
|
|
|