|
next
|
 Subject: Need Help Resorting Author: Ivan Pedruzzi Date: 06 Jul 2005 10:07 PM
|
Brian,
Try the following solution and see if meets your requirements
Hope this helps
Ivan Pedruzzi
Stylus Studio Team
<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html"/>
<xsl:param name="MaxItems" select="21"/>
<xsl:param name="Columns" select="3"/>
<xsl:template match="/">
<html>
<body>
<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(date, 4,2), '00'))"/>
<xsl:copy-of select="."/>
</xsl:for-each>
</xsl:copy>
</xsl:for-each>
</xsl:variable>
<xsl:variable name="ItemsByTitle">
<xsl:for-each select="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>
<a><strong>Order by date</strong></a>
<xsl:apply-templates select="$ItemsByDate/rss"/>
<a><strong>Order by title</strong></a>
<xsl:apply-templates select="$ItemsByTitle/rss"/>
</body>
</html>
</xsl:template>
<xsl:template match="rss">
<table border="1" cellspacing="0" width="700">
<tr>
<xsl:for-each select="item">
<!--
position() returns the position in the document order
-->
<xsl:if test="position() <= $MaxItems">
<xsl:if test="position() mod $Columns = 1">
<tr/>
</xsl:if>
<xsl:apply-templates select="."/>
</xsl:if>
</xsl:for-each>
</tr>
</table>
</xsl:template>
<xsl:template match="item">
<td width="228" height="194" class="photoTD" id="tableframe" MCFocusable="true">
<table height="140" cellSpacing="0" cellPadding="0" width="100" border="0">
<span class="btnMedia_nofocus">
<tr>
<td vAlign="center" align="middle">
<xsl:value-of select="image" disable-output-escaping="yes"/>
</td>
</tr>
</span>
</table>
<div class="text3">
<nobr>
<xsl:value-of select="title"/>
<br/>
<xsl:value-of select="date"/>
</nobr>
</div>
</td>
<td height="20"></td>
</xsl:template>
</xsl:stylesheet>
|
next
|
 Subject: Need Help Resorting Author: Ivan Pedruzzi Date: 07 Jul 2005 01:12 AM
|
we are getting closer :)
Ivan
<?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="21"/>
<xsl:param name="Columns" select="3"/>
<xsl:template match="/">
<html>
<body>
<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>
<a><strong>Order by date</strong></a>
<xsl:apply-templates select="msxml:node-set($ItemsByDateShort)/rss"/>
<a><strong>Order by title</strong></a>
<xsl:apply-templates select="msxml:node-set($ItemsByTitleShort)/rss"/>
</body>
</html>
</xsl:template>
<xsl:template match="rss">
<table border="1" cellspacing="0" width="700">
<tr>
<xsl:for-each select="item">
<xsl:if test="position() mod $Columns = 1">
<tr/>
</xsl:if>
<xsl:apply-templates select="."/>
</xsl:for-each>
</tr>
</table>
</xsl:template>
<xsl:template match="item">
<td width="228" height="194" class="photoTD" id="tableframe" MCFocusable="true">
<table height="140" cellSpacing="0" cellPadding="0" width="100" border="0">
<span class="btnMedia_nofocus">
<tr>
<td vAlign="center" align="middle">
<xsl:value-of select="image" disable-output-escaping="yes"/>
</td>
</tr>
</span>
</table>
<div class="text3">
<nobr>
<xsl:value-of select="title"/>
<br/>
<xsl:value-of select="date"/>
</nobr>
</div>
</td>
<td height="20"></td>
</xsl:template>
</xsl:stylesheet>
|
|
|
|