Peter Laman wrote:
My XML data contains elements with a date attribute. I need to write
an XSLT transformation that only selects the elements for the current
month. Is that possible with XSLT only, or should I preselect the data
a different way?
It's simple if your dates are in a consistent format, for example
'yyyy-mm-dd'. In XSLT 1.0:
<xsl:template match="element[starts-with(@date, '2008') and
substring(@date, 6, 2) = '04']">
or using a key:
<xsl:key name="months" match="element[starts-with(@date, '2008')]"
use="substring(@date, 6, 2)"/>
...
<xsl:apply-templates select="key('months', '04')"/>