Re: [xsl] Comparing Integers

Subject: Re: [xsl] Comparing Integers
From: David Carlisle <davidc@xxxxxxxxx>
Date: Wed, 17 Oct 2007 18:42:10 +0100
As Mike has said this is much easier in xslt 2, which has date
arithmetic.

> select="concat(substring($currentTime, 1,4)....etc etc

without knowing what the etc here is can't comment really on whether the
rest of the code is right, but some observations and guesses....



> <xsl:variable
> name="currentTime">2007-10-04T09:00:00.0000000+01:00</xsl:variable>

it's always better to do

<xsl:variable name="currentTime" select="'2007-10-04T09:00:00.0000000+01:00'"/>

so you make a string rather than a result tree fragment.

Conversely

> <xsl:variable name="within24Hours"
> select="number($submissionDeadlineString + 1000000)"/>

number() here isn't needed as the result of + will already be a number.
But neither of those comments affects your result.

Your definition of  within24Hours, within10Days etc seem to assume that
changing the date by those amounts is equivalent to  adding a constant
value to the number corresponding to a date, without seeing exactly what
your "etc" is it's hard to be sure but this seems unlikely. Don't you
need to take account of month lengths and year ends, etc.


2007-10-04 + 1 day is 2007-10-05 
but
2007-10-31 + 1 day is 2007-11-01

if your test is

20071004 + 1 >= 20071005
20071031 + 1 >= 20071101

then it will be true in the first case and not in the second.


David

________________________________________________________________________
The Numerical Algorithms Group Ltd is a company registered in England
and Wales with company number 1249803. The registered office is:
Wilkinson House, Jordan Hill Road, Oxford OX2 8DR, United Kingdom.

This e-mail has been scanned for all viruses by Star. The service is
powered by MessageLabs. 
________________________________________________________________________

Current Thread