Hi all,
I'm hoping that someone on here will have come across something like this before and be able to help.
I've got an xml document that is returned to me via a webservice so i can;t change it. the document looks like this:
the dates in this are in the yyyy-mm-dd format, and the output that i want is to group the same year and month together:
now i found a really good article that does exactly what i want it to do, with their data set and their node names etc, but when i try and apply that to my xml document it just doesn;t work and i don;t understand it enough to figure out why it is going wrong.
This is my code at the moment:
this code just outputs all of the dates where as what should happen is the duplicate 2009-11 shouldn't be shown.
Any ideas?
Thanks in advance
Tony
I'm hoping that someone on here will have come across something like this before and be able to help.
I've got an xml document that is returned to me via a webservice so i can;t change it. the document looks like this:
Code:
<root>
<news>
<data alias="date">2008-10-20</data>
</news>
<news>
<data alias="date">2009-11-25</data>
</news>
<news>
<data alias="date">2009-11-20</data>
</news>
<news>
<data alias="date">2009-03-20</data>
</news>
<news>
<data alias="date">2008-01-20</data>
</news>
</root>
the dates in this are in the yyyy-mm-dd format, and the output that i want is to group the same year and month together:
Code:
2009-11
2009-03
2008-10
2008-01
now i found a really good article that does exactly what i want it to do, with their data set and their node names etc, but when i try and apply that to my xml document it just doesn;t work and i don;t understand it enough to figure out why it is going wrong.
This is my code at the moment:
Code:
<xsl:stylesheet version="1.0" xmlns:xsl="[URL unfurl="true"]http://www.w3.org/1999/XSL/Transform">[/URL]
<xsl:key name="contacts-by-surname" match="news" use="surname" />
<xsl:template match="root">
<ul>
<xsl:for-each select="news[count(. | key('contacts-by-surname', substring(data, 0,8))[1]) = 1]">
<xsl:sort select="substring(data, 0, 8)" order="descending"/>
<li>
<xsl:value-of select="substring(data, 0, 8)" />
</li>
</xsl:for-each>
</ul>
</xsl:template>
</xsl:stylesheet>
this code just outputs all of the dates where as what should happen is the duplicate 2009-11 shouldn't be shown.
Any ideas?
Thanks in advance
Tony