Re: [xsl] showing unique element values only

Subject: Re: [xsl] showing unique element values only
From: Jeni Tennison <mail@xxxxxxxxxxxxxxxx>
Date: Thu, 1 Feb 2001 14:25:13 +0000
Hi Keith,

> I've tried manipulating the order of the ACHFee element with
> <xsl:sort select="feeLevelBottom"/> and so-on. I've used every
> combination of preceding::, following::, following-sibling:: that I
> can come up with, but I still cannot make ONLY UNIQUE cell contents
> be displayed

Here's what you're missing: axes *always* operate on the structure of
the original XML, it don't matter how much you sort or what axes you

At the moment you trying to do (roughly)

  for each ACHfee
    sorted according to feeLevelBottom
       if you haven't already processed something with the same
          then process this one

Instead, you need to turn it around so that you only select the first
ACHfees with a particular feeLevelBottom in the first place, iterate
over them, and sort *them* according to the feeLevelBottom.

For example:

<xsl:for-each select="//ACHFee
                       [not(feeLevelBottom =
   <xsl:sort select="feeLevelBottom" />
You may find it more efficient to use the Muenchian Method to get the
list of fees with unique feeLevelBottoms.  Define a key:

<xsl:key name="fees"
         use="number(feeLevelBottom)" />

And then select the ACHFees with unique feeLevelBottom values with:

             [count(.|key('fees', number(feeLevelBottom))[1]) = 1]">
   <xsl:sort select="feeLevelBottom" />

I hope that helps,


Jeni Tennison

 XSL-List info and archive:

Current Thread