Reputation: 2655
I'm having a small issue with the XSLT ...
Basically i have following xml:
<Root>
<Node>
<Prop1></Prop1>
<Prop2></Prop2>
<Date>03/05/2013</Date>
...
</Node>
<Node>
<Prop1></Prop1>
<Prop2></Prop2>
<Date>01/01/2012</Date>
...
</Node>
</Root>
From this i generate a table it looks something like this:
<table>
<tr>
<th colspan="2" style="text-align:left;">
<u>
Table:
</u>
</th>
</tr>
<xsl:for-each select="Root/Node[current-date() < date]">
<xsl:sort select="date" />
<tr>
<td><xsl:value-of select="prop1"/></td>
<td>
...
</td>
<td><xsl:value-of select="date"/></td>
</tr>
</xsl:for-each>
</table>
I would like to get only the nodes which the date is overdue, basically date < currentdate
Any idea how i could achieve it?
Upvotes: 0
Views: 607
Reputation: 101730
Please firstly bear in mind that XPath is case sensative and that Node
will not match an element if its name is actually Node1
or Node2
.
Supposing that you are working with XSLT 1.0, there isn't a built-in way to get the current date, so you would need to pass it in as a parameter. If you can get that working, something like this should do the trick:
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" indent="yes"/>
<xsl:param name="currentDate" />
<xsl:template match="/">
<table>
<tr>
<th colspan="2" style="text-align:left;">
<u>
Table:
</u>
</th>
</tr>
<xsl:apply-templates select="Root/*[translate($currentDate, 'T:-', '') <
translate(Date, 'T:-', '')]">
<xsl:sort select="Date" />
</xsl:apply-templates>
</table>
</xsl:template>
<xsl:template match="Root/*">
<tr>
<td>
<xsl:value-of select="Prop1"/>
</td>
<td>
...
</td>
<td>
<xsl:value-of select="Date"/>
</td>
</tr>
</xsl:template>
</xsl:stylesheet>
Upvotes: 1