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
Topic Page 1 2 3 4 5 6 7 8 9 Go to previous topicPrev TopicGo to next topicNext Topic
Postnext
Dominic NeagleSubject: Comparing Dates With ASP.NET 2.0 And XSLT
Author: Dominic Neagle
Date: 08 Jan 2008 04:20 AM
Originally Posted: 08 Jan 2008 04:19 AM
Hi all,

Basically, my question is, how can I compare to dates?

The dates are in the following format:

<date>08/01/2008 9:13:45</date>

What I need to do is compare the date in the XML file (as shown above) with another date (that gets passed into the XSLT file). If the first date (from the XML file) is greater than the second date (which was passed in) then I need it to display the date.

My code is the following:


<!-- value passed in from a .NET page -->
<xsl:param name="date_start"></xsl:param>

<xsl:if test="Date &gt; $date_start">
<p><xsl:value-of select="DateTime" /></p>
</xsl:if>


The trouble is, even when the condition returns true, the date is never output.

Is the date in the correct format for comparison, or do I need to change it somehow? The process that creates the XML file containing the dates can't really be changed, so the dates have to be recorded in the format that they are currently, so will I have to do some jiggling about with the format from within the XSLT stylesheet?

If it helps, I'm using ASP.NET 2.0 web pages to actually apply the XSLT stylesheet to the XML file and display the results, so I'm not entirely sure what processor is being used. I imagine the .NET Framework has it's own processor built in. I'm also not using (and cant install) any EXSLT thing-me-bobs.

Any help would be muchos appreciated! Thanks!

:)

Postnext
Tony LavinioSubject: Comparing Dates With ASP.NET 2.0 And XSLT
Author: Tony Lavinio
Date: 08 Jan 2008 04:00 PM
Since you are using the .net processor, you're limited to XSLT 1.0
if you want to go the XSLT route, which means no date arithmetic.

You could parse the date and turn it into an integer (year * 31 * 12
+ month * 31 + day would be good enough for comparison purposes).

But this is a Stylus Studio support forum, and this doesn't appear to
be a Stylus Studio-related question.

Posttop
Dominic NeagleSubject: Comparing Dates With ASP.NET 2.0 And XSLT
Author: Dominic Neagle
Date: 09 Jan 2008 03:33 AM
Thanks for your help. I ended up converting the date to yyyyMMdd format, which as you say, seems to work fine for comparison reasons.

I know my question wasn't exactly related to Stylus Studio, but I thought this was a forum for helping with general XML/XSLT problems as well. It certainly seems to be the best place I've found! And I have to say, I've used Stylus Studio in my spare time, but unfortunately we don't use it here at work.

:(

Again though, thanks for your help.

 
Topic Page 1 2 3 4 5 6 7 8 9 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.