[Solved] Tokenize and compare dates in xslt 1.0


Xalan supports the EXSLT str:tokenize() function, so that will take care of that. After that, you just need to sort the tokens by the individual date & time components, and grab the last one.

<xsl:for-each select="str:tokenize($dates, ';')">
    <!-- sort by year -->
    <xsl:sort select="substring(., 9, 4)"/>
    <!-- sort by month -->
    <xsl:sort select="string-length(substring-before('JanFebMarAprMayJunJulAugSepOctNovDec', substring(., 1, 3)))" data-type="number"/>
    <!-- sort by day -->
    <xsl:sort select="substring(., 5, 2)"/>
    <!-- sort by time -->
    <xsl:sort select="substring(., 14, 4)"/>
    <xsl:if test="position()=last()">
        <xsl:value-of select="."/>
    </xsl:if>
</xsl:for-each>

Note that this will not work if your dates are not all in the same format (in your input, the last date does not have a space between month and day).

7

solved Tokenize and compare dates in xslt 1.0