Re: [xsl] Removing duplicates after list is sorted

Subject: Re: [xsl] Removing duplicates after list is sorted
From: Wendell Piez <wapiez@xxxxxxxxxxxxxxxx>
Date: Wed, 10 May 2006 14:56:11 -0400
Dear Nicole,

At 01:39 PM 5/10/2006, you wrote:
<xsl:apply-templates select="//Document/Report">
                                <xsl:sort order='ascending'
                                <xsl:sort order='descending'

In XSL 1.0 you can't de-duplicate within the results of your sort, but you can de-duplicate before sorting, which has the same effect:

<xsl:apply-templates select="//Document/Report[ deduplication logic goes here ]">
<xsl:sort ... </xsl:apply-templates>

inside the predicate (the bracketed expression, used as a "filter expression"), place the same test as you are currently using in the template to de-duplicate.

As you can imagine, when things get very complex you may not want to do it this way, at which point you will want to consider whether to try to handle it entirely in 1.0 (not built for the job, but solutions have been developed), or in 2.0 (which is built for the job and much better at this sort of thing generally).

I hope that helps,

Wendell Piez                            mailto:wapiez@xxxxxxxxxxxxxxxx
Mulberry Technologies, Inc.      
17 West Jefferson Street                    Direct Phone: 301/315-9635
Suite 207                                          Phone: 301/315-9631
Rockville, MD  20850                                 Fax: 301/315-8285
  Mulberry Technologies: A Consultancy Specializing in SGML and XML

Current Thread