I have an xml document containing a list of 'Events' which ultimately gets presented to end users. How can I filter out data whose date is in the past?
[1] Using short year yy format can cause problem no end. Better use long year ccyy format. If that's legacy, just pay more attention to epoche year-zero.
[2] The main problem ironically is the "today"/"now". Using xsl without extension, one cannot set the today automatically.
Let me illustrate the approach for [1] ccyy year and [2] hard coded "today". The xsl transform the original document into including only future (including today) events.
Let's say the xml source file:
[tt]
<Events>
<Event>
<Date>08/24/2006</Date>
</Event>
<Event>
<Date>09/24/2006</Date>
</Event>
<!-- this is added, it is today event -->
<Event>
<Date>09/04/2006</Date>
</Event>
</Events>
[/tt]
The xsl source file can be scripted like this.
[tt]
<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="
</xsl:stylesheet>
[/tt]
It can thereby easily generalized to retrieve the past rather than the future. Generalization can be investigated on the coding design as well. In any case, that shows the essential for the purpose.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.