RE: [xsl] Extract unique values

Subject: RE: [xsl] Extract unique values
From: "SINGH Navpreet" <Navpreet.SINGH@xxxxxxxxx>
Date: Fri, 24 Mar 2006 10:26:52 +1100
Thanks for your response. Should have used distinct-values() function at
first place.

-----Original Message-----
From: G. Ken Holman [mailto:gkholman@xxxxxxxxxxxxxxxxxxxx]
Sent: Friday, 24 March 2006 9:59 AM
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject: Re: [xsl] Extract unique values


At 2006-03-24 09:46 +1100, SINGH Navpreet wrote:
>I want to extract all the <c> from the following xml with uniqe
>values. So in the transformed, no two <c> element should have same
values.

This is a FFFFFFAQ.  Finding uniqueness is a subset of the grouping
problem, so search the web for XSLT Grouping.

In our XSLT 1 training classes we teach that there are three ways to
find uniqueness:  using axes, using keys (the Muenchian method)
http://www.jenitennison.com/xslt/grouping/, and using variables
http://www.biglist.com/lists/xsl-list/archives/200401/msg00070.html
... each with pros and cons:

Axis method:
  - cons - slow, only sibling-wide or document-wide contexts

Key method:
  - pros - fastest, filtering done in predicates
  - cons - document-wide context

Variable method:
  - pros - document wide, sub-document, or multi-document contexts
         - faster than axis method
  - cons - slower than key method
         - filtering not done in predicates

Grouping is built in to XSLT 2 as a language feature.

I hope this helps.

. . . . . . . . Ken

--
Upcoming XSLT/XSL-FO hands-on courses: Washington,DC 2006-06-12/16
World-wide on-site corporate, govt. & user group XML/XSL training.
G. Ken Holman                 mailto:gkholman@xxxxxxxxxxxxxxxxxxxx
Crane Softwrights Ltd.          http://www.CraneSoftwrights.com/s/
Box 266, Kars, Ontario CANADA K0A-2E0    +1(613)489-0999 (F:-0995)
Male Cancer Awareness Aug'05  http://www.CraneSoftwrights.com/s/bc
Legal business disclaimers:  http://www.CraneSoftwrights.com/legal

Current Thread