Subject: [xsl] RE: Testing / Comparing dates: Solution From: Aaron Johnson <Aaron2.Johnson@xxxxxxxxx> Date: Fri, 24 Mar 2006 15:38:27 +0000 |
Thanks to Jeni T... http://www.xslt.com/html/xsl-list/2001-04/msg00232.html Here you go: <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> <xsl:param name="currentDate"/> <xsl:variable name="firstDate" select="concat(substring($currentDate, 1,4),substring($currentDate, 6,2),substring($currentDate, 9,2))"/> <xsl:template match="/"> <xsl:apply-templates select="//item"/> </xsl:template> <xsl:template match="item"> <xsl:variable name="secondDate" select="concat(substring(submissionDeadline, 1,4),substring(submissionDeadline, 6,2),substring(submissionDeadline, 9,2))"/> <xsl:choose> <xsl:when test="$firstDate > $secondDate"> <xsl:call-template name="late"/> </xsl:when> <xsl:when test="$firstDate < $secondDate"> <xsl:call-template name="ontime"/> </xsl:when> <xsl:when test="$firstDate = $secondDate"> <xsl:call-template name="same"/> </xsl:when> <xsl:otherwise>Monkeys<br /></xsl:otherwise> </xsl:choose> </xsl:template> <xsl:template name="ontime"> This is on time </xsl:template> <xsl:template name="late"> This is late </xsl:template> <xsl:template name="same"> This is on time </xsl:template> </xsl:stylesheet> .................................................................. Aaron Johnson GUI / XSLT development Academic Technologies Group [ATG] University of the West of England 0117 3281051 [ext: 81051] atg.uwe.ac.uk/aaron SECURITY POLICY: Please note that ATG will only accept e-mail attachments in the following formats: .asp,.bin,.doc,.gif,.html,.jpg,.mdb,.png, .psd,.shtml,.sdf,.sit,.xls,.xml,.xsd,.xsl,.zip, .................................................................. B3In a wireless world without boundaries... ...who needs Gates and Windows?B2 .................................................................. This communication is intended solely for the use of the individual(s) to whom it is addressed. Any opinions presented are those of the author and do not necessarily represent the University of the West of England, Bristol. .................................................................. ------ Forwarded Message From: Aaron Johnson <aaron2.johnson@xxxxxxxxx> Date: Fri, 24 Mar 2006 10:59:40 +0000 To: "xsl-list@xxxxxxxxxxxxxxxxxxxxxx" <xsl-list@xxxxxxxxxxxxxxxxxxxxxx> Conversation: Testing / Comparing dates Subject: Testing / Comparing dates Hello... I have some xml: <submissionDeadline>2006-17-12</submissionDeadline> I would like to test this element against a parameter containing the current date so as to display two lists, a list of items on time and a list of items that are late. As far as I am aware, the parameter will be the same format. I thought if the dates were passed as integers [20061712] it may be possible to do a greater than of less than test. Can you compare dates as they are in this form, and if so, how? Thanks for your advice... .................................................................. Aaron Johnson GUI / XSLT development Academic Technologies Group [ATG] University of the West of England 0117 3281051 [ext: 81051] atg.uwe.ac.uk/aaron SECURITY POLICY: Please note that ATG will only accept e-mail attachments in the following formats: .asp,.bin,.doc,.gif,.html,.jpg,.mdb,.png, .psd,.shtml,.sdf,.sit,.xls,.xml,.xsd,.xsl,.zip, .................................................................. B3In a wireless world without boundaries... ...who needs Gates and Windows?B2 .................................................................. This communication is intended solely for the use of the individual(s) to whom it is addressed. Any opinions presented are those of the author and do not necessarily represent the University of the West of England, Bristol. .................................................................. ------ End of Forwarded Message This email has been independently scanned for viruses and any virus software has been removed using McAfee anti-virus software
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] Testing / Comparing dates, Michael Kay | Thread | RE: [xsl] Testing / Comparing dates, Andrew Smith |
RE: [xsl] Using a variable as the x, Michael Kay | Date | Re: [xsl] msxml and removing parame, Joe Fawcett |
Month |