RE: [xsl] Unique entries from substrings

Subject: RE: [xsl] Unique entries from substrings
From: "Aron Bock" <aronbock@xxxxxxxxxxx>
Date: Mon, 27 Jun 2005 03:46:16 +0000

You could approach it as a grouping problem, in which case this input:

<REPORT_ACCESS> <REPORTS> <REPORT> <!-- not unique in list --> <DATE>07/08/2005</DATE> </REPORT> <REPORT> <!-- unique --> <DATE>05/08/2005</DATE> </REPORT> <REPORT> <!-- not unique in list --> <DATE>07/08/2005</DATE> </REPORT> <REPORT> <!-- unique 05-2005--> <DATE>05/09/2005</DATE> </REPORT> <REPORT> <!-- unique 07-2005--> <DATE>07/09/2005</DATE> </REPORT> </REPORTS> </REPORT_ACCESS>

with this xsl:

<?xml version="1.0" encoding="iso8859-1"?>
<xsl:stylesheet version="1.0" xmlns:xsl="";>
<xsl:output method="xml" indent="yes"/>
<xsl:strip-space elements="*"/>

<xsl:key match="DATE" name="kDates" use="concat(substring(., 1, 2), substring(., 7))"/>

   <xsl:template match="DATE[generate-id(.) = generate-id(
           key('kDates', concat(substring(., 1, 2), substring(., 7)))[1])
       <xsl:value-of select="concat(substring(., 1, 2), substring(., 7))"/>

<xsl:template match="DATE"/>



<?xml version="1.0" encoding="UTF-8"?>

Of course, you may have to adjust to include the day, etc ... in which case you wouldn't need the substring and concat business.


Express yourself instantly with MSN Messenger! Download today - it's FREE!

Current Thread