xslt 2.0 compare current date to start and end date

date, xslt, xslt-2.0

Solution

I believe it goes like this:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
exclude-result-prefixes="xs">
...
<xsl:for-each select="forms/form">
  <xsl:choose>
    <xsl:when test="xs:date(start) &lt;= current-date() 
                    and 
                    current-date() &lt;= xs:date(end)">
        <!-- in progress -->
    </xsl:when>

    <xsl:otherwise>
        <!-- not started yet or already ended-->
    </xsl:otherwise>
  </xsl:choose>
</xsl:for-each>

Problem

I have the following output: ``` <forms> <form id="15"> <start>2013-12-09</start> <end>2014-01-05</end> </form> </forms> ``` I would like to test to see if current date is equal or greater to "start" and lesser or equal to "end" How would I go about testing for this? What I had in mind is: ``` <xsl:variable name="fstart"> <xsl:value-of select="start" /> </xsl:variable> <xsl:variable name="fend"> <xsl:value-of select="end" /> </xsl:variable> <xsl:choose> <xsl:when test="$fstart >= currentdate xor currentdate <= $fend "> <!-- do stuff --> </xsl:when> <xsl:otherwise> </xsl:otherwise> </xsl:choose> ```

Original source