Good morning, i have checked many responses about this topic, but without success...very sorry...
i have got an xml document with an element 'courses' ("seances") which has 'course' éléments ("seance") : (i have deleted unnecessary details)
....
<seances>
<seance date="2014-09-10T00:00:01">
...details in a 'seance'
</seance>
<seance date="2013-09-10T00:00:01">
...
</seance>
...other 'seance' elements
</seances>
and my xslt stylesheet produces an html document :
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0"
xmlns:date="http://exslt.org/dates-and-times"
extension-element-prefixes="date"
xmlns:gr="http://www.w3.org/2000/svg" >
<xsl:output method="html" encoding="iso-8859-1" indent="yes" />
<xsl:import href="date.xsl" />
to memorize the date of the day :
<xsl:variable name="ddj" as="xs:dateTime" select="date:date-time()"/>
i would like to show only an element course when the date of the course is ok (the date is not in the future) :
i have tried many conditions like this one but it is always false :
<xsl:template match="seance">
<xsl:variable name="dateseance" as="xs:dateTime" select="@date"/>
<xsl:value-of select="$dateseance" /><xsl:value-of select="$ddj" />
<xsl:choose>
<xsl:when test="$ddj >= $dateseance">
<xsl:text>-OK-</xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:text>-Not OK-</xsl:text>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
Dates seems to be ok, but it prints :
2014-09-10T00:00:012013-09-11T10:00:00.004+02:00-Not OK- (will not be printed !)
other lines should be "ok" :
2013-09-10T00:00:012013-09-11T10:00:00.004+02:00-Not OK- 2012-09-10T00:00:012013-09-11T10:00:00.004+02:00-Not OK- 2012-09-10T00:00:012013-09-11T10:00:00.004+02:00-Not OK- 2012-09-10T00:00:012013-09-11T10:00:00.004+02:00-Not OK- 2012-09-10T00:00:012013-09-11T10:00:00.004+02:00-Not OK-
i hope that it can be understood...
many thanks for any help.
A precision : i process it in mozilla/firefox
There appears to be no problem when using the built-in facilities in XSLT 2.0 for date and time:
Is there a reason you feel the need to use exslt?
Below is an XSLT 1.0 solution that ignores time zones and assumes both date/time values are in the same time zone:
This works because it converts the date/time values into numbers which, in XSLT 1.0, can be compared using
>
and<
.