[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Release Date vs. Highlight Until Date

Subject: Re: Release Date vs. Highlight Until Date
From: John <john-xsl-list@xxxxxxxx>
Date: Wed, 29 Sep 2004 08:33:11 -0700
date vs datetime
Thanks to everyone who responded on this thread. I did have some time to read parts of an old copy of White's "Mastering XSLT" (not the best intro I think) over the weekend, and ordered another recommendation. I still don't understand why/when to use for-each and when to use apply-templates, but I seem to prefer for-each. I have restructured the XML and implemented a variety of the suggested techniques. One thing I'm still strugling with is how to select the date value for sorting. Say I have XML something like the following:

<items>
 <item release="20031212T121212" highlight="20041212T121212" />
</item>

where there could be any number of item elements. I want to select for sort one of the attributes from each item and use that in the sort. The attribute I want is release unless highlight is less than sysdate. Right now I am getting sysdate and doing the logic with extensions, but I would prefer to avoid this (I know I can get rid of the sysdate extension with parameters but I am more concerned about the comparison extension). My C# extension looks like this (I can't even be sure this is the right logic - it *seems* to work - but hopefully you get the idea). Thanks in advance to anyone who can convert this to pure XSL.

public string SortNewsDate( string strSysDate, string strHighlightUntilDate, string strReleaseDate )
{
DateTime dtResult = DateTime.MinValue;


try
{
if ( strSysDate != null && ! strSysDate.Equals( "" ))
{
if ( strHighlightUntilDate != null && ! strHighlightUntilDate.Equals( "" ))
{
dtResult = DateTime.ParseExact( strHighlightUntilDate, SC_DATE_FORMAT, null );
}


if ( dtResult.CompareTo( DateTime.ParseExact( strSysDate, SC_DATE_FORMAT, null )) < 0
&& strReleaseDate != null && ! strReleaseDate.Equals( "" ))
{
dtResult = DateTime.ParseExact( strReleaseDate, SC_DATE_FORMAT, null );
}
}
}
catch( Exception ex )
{
throw new Exception( ex.Message + strSysDate + " : " + strHighlightUntilDate + " : " + strReleaseDate );
}


           return( dtResult.ToString( SC_DATE_FORMAT ));
       }

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.