XML Editor
Sign up for a WebBoard account Sign Up Keyword Search Search More Options... Options
Chat Rooms Chat Help Help News News Log in to WebBoard Log in Not Logged in
Show tree view Topic
Go to previous topicPrev TopicGo to next topicNext Topic
Postnext
Brian BSubject: 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() &lt;= $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

Posttop
Tony LavinioSubject: Need help with a XSL file
Author: Tony Lavinio
Date: 19 Jun 2007 02:07 PM
1. Please don't ask XSLT questions in an XQuery forum.
2. These forums are for Stylus Studio users. We do not
recognize your email; if you are a registered user but
prefer to use an alternate email address here, please at
least state your version of Stylus Studio when you post
so we can test against the same version you are using.
Thank you.

 
Go to previous topicPrev TopicGo to next topicNext Topic
Download A Free Trial of Stylus Studio 6 XML Professional Edition Today! Powered by Stylus Studio, the world's leading XML IDE for XML, XSLT, XQuery, XML Schema, DTD, XPath, WSDL, XHTML, SQL/XML, and XML Mapping!  
go

Log In Options

Site Map | Privacy Policy | Terms of Use | Trademarks
Stylus Scoop XML Newsletter:
W3C Member
Stylus Studio® and DataDirect XQuery ™are from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2016 All Rights Reserved.