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

RE: Comparing Integers

Subject: RE: Comparing Integers
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Wed, 17 Oct 2007 18:03:03 +0100
RE:  Comparing Integers
Are you doing this in XSLT 1.0 or 2.0? 

In 2.0 you can compare these values directly by casting them to xs:dateTime
and then subtracting to get the difference as an xs:dayTimeDuration.

In 1.0 you may be able to take advantage of the library routines at
www.exslt.org.

Michael Kay
http://www.saxonica.com/ 

> -----Original Message-----
> From: Aaron Johnson [mailto:artpunx@xxxxxxxxx] 
> Sent: 17 October 2007 17:55
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject:  Comparing Integers
> 
> Hello...
> 
> I have set up some tests to compare Integers, but wish to 
> refine the comparison. I have some xml:
> 
> <submissionDeadline>2027-10-04T09:00:00.0000000-00:00</submiss
> ionDeadline>
> <submissionDeadline>2007-10-03T09:00:00.0000000-00:00</submiss
> ionDeadline>
> <submissionDeadline>2007-10-01T08:00:00.0000000+01:00</submiss
> ionDeadline>
> <submissionDeadline>2007-09-10T12:00:00.0000000+01:00</submiss
> ionDeadline>
> 
> 
> This is selected and concatenated into an integer:
> 
> <xsl:variable name="submissionDeadlineString"
> select="concat(substring(submissionDeadline, 1,4)... etc etc
> 
> I then concatenate the current time / date etc:
> 
> <xsl:variable 
> name="currentTime">2007-10-04T09:00:00.0000000+01:00</xsl:variable>
> <xsl:variable name="currentTimeString"
> select="concat(substring($currentTime, 1,4)....etc etc
> 
> ...then test against each other:
> 
> <xsl:when test="$currentTimeString &lt; = 
> $submissionDeadlineString"><xsl:call-template
> name="ontime"/></xsl:when>
> 
> I would like to be able to test for 4 different outcomes, 
> ontime, within24Hours, within10Days and past10Days. I have 
> set up variable and tests thus far:
> 
> <xsl:variable 
> name="currentTime">2007-10-04T09:00:00.0000000+01:00</xsl:variable>
> <xsl:variable name="currentTimeString"
> select="concat(substring($currentTime, 1,4)....etc etc 
> <xsl:variable name="within24Hours"
> select="number($submissionDeadlineString + 1000000)"/> 
> <xsl:variable name="within10Days"
> select="number($submissionDeadlineString + 1000001)"/> 
> <xsl:variable name="past10Days"
> select="number($submissionDeadlineString + 10000001)"/>
> 
> <xsl:choose>
> <xsl:when test="$currentTimeString &lt; = 
> $submissionDeadlineString"><xsl:call-template
> name="ontime"/></xsl:when>
> <xsl:when test="$currentTimeString &lt; = 
> $within24Hours"><xsl:call-template
> name="twentyFourHourRule"/></xsl:when>
> <xsl:when test="$currentTimeString &lt; = 
> $within10Days"><xsl:call-template 
> name="tenDayRule"/></xsl:when> <xsl:when 
> test="$currentTimeString &gt; = 
> $past10Days"><xsl:call-template 
> name="plusTenDay"/></xsl:when> </xsl:choose>
> 
> ...so far, only the "ontime" and "plusTenDay" tests work.
> 
> Am I headed in the right direction? Can anyone offer any 
> advice please?
> 
> Thank you.

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.