I have a structure like this:
<Info ID="1">
...
<Date>2009-04-21</Date>
</Info>
<Info ID="2">
...
<Date>2009-04-22</Date>
</Info>
<Info ID="3">
...
<Date>2009-04-20</Date>
</Info>
I want to get the latest date using XSLT (in this example - 2009-04-22).
XSLT 2.0+:
<xsl:perform-sort>
is used when we want to sort elements without processing the elements individually.<xsl:sort>
is used to process elements in sorted order. Since you just want the last date in this case, you do not need to process each<Info>
element. Use<xsl:perform-sort>
:In XSLT 2.0 or later, you shouldn't need to sort at all; you can use
max()
...Figured it out, wasn't as hard as I thought it will be: