agiuswiltonites(_at_)juno(_dot_)com wrote:
Existing XML:
<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<url>
<loc>http://www.example.com/first</loc>
<lastmod>2012-01-27T10:18:26+00:00</lastmod>
<priority>0.90</priority>
<changefreq>daily</changefreq>
</url>
<url>
<loc>http://www.example.com/second</loc>
<lastmod>2012-03-16T07:38:42+00:00</lastmod>
<priority>0.60</priority>
<changefreq>weekly</changefreq>
</url>
<url>
<loc>http://www.example.com/second</loc>
<lastmod>2012-03-16T08:36:44+00:00</lastmod>
<priority>0.60</priority>
<changefreq>weekly</changefreq>
</url>
<url>
<loc>http://www.example.com/third</loc>
<lastmod>2012-03-16T08:37:09+00:00</lastmod>
<priority>0.60</priority>
<changefreq>weekly</changefreq>
</url>
</urlset>
Desired Output:
<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<url>
<loc>http://www.example.com/first</loc>
<lastmod>2012-01-27T10:18:26+00:00</lastmod>
<priority>0.90</priority>
<changefreq>daily</changefreq>
</url>
<url>
<loc>http://www.example.com/second</loc>
<lastmod>2012-03-16T07:38:42+00:00</lastmod>
<priority>0.60</priority>
<changefreq>weekly</changefreq>
</url>
<loc>http://www.example.com/third</loc>
<lastmod>2012-03-16T08:37:09+00:00</lastmod>
<priority>0.60</priority>
<changefreq>weekly</changefreq>
</url>
</urlset>
The can be done with Muenchian grouping as follows:
<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:s09="http://www.sitemaps.org/schemas/sitemap/0.9"
exclude-result-prefixes="s09"
version="1.0">
<xsl:output indent="yes"/>
<xsl:strip-space elements="*"/>
<xsl:key name="url-by-loc" match="s09:url" use="s09:loc"/>
<xsl:template match="@* | node()">
<xsl:copy>
<xsl:apply-templates select="@* | node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="s09:urlset">
<xsl:copy>
<xsl:apply-templates select="s09:url[generate-id() =
generate-id(key('url-by-loc', s09:loc)[1])]"/>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
--
Martin Honnen --- MVP Data Platform Development
http://msmvps.com/blogs/martin_honnen/
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--