[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] 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 < = > $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 < = > $submissionDeadlineString"><xsl:call-template > name="ontime"/></xsl:when> > <xsl:when test="$currentTimeString < = > $within24Hours"><xsl:call-template > name="twentyFourHourRule"/></xsl:when> > <xsl:when test="$currentTimeString < = > $within10Days"><xsl:call-template > name="tenDayRule"/></xsl:when> <xsl:when > test="$currentTimeString > = > $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.
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|