Sign In/My Account | View Cart  
advertisement

Article:
 Finding the First, Last, Biggest, Smallest
Subject: eliminating duplicates
Date: 2002-08-13 06:08:56
From: charles asafo

This is another good one. Keep it up!
I have a simple question.
How can I eliminate duplicates after sorting?
The following :
-- boy
-- boy
-- girl
-- man
-- man
-- woman
should become
-- boy
-- girl
-- man
-- woman
after eliminating duplicates.
Any suggestion?
Thanks
(ca).

No Previous Message Previous Message   Next Message No Next Message


Titles Only Titles Only Oldest First
  • eliminating duplicates
    2003-08-22 07:17:12 Gonzalo Huerta [Reply]

    You can use something like this:
    --
    <xsl:for-each select="//Nodes/Type[not(.=preceding::Type)]">
    <xsl:sort select="Type"/>
    <xsl:variable name="actualType" select="."/>
    <Type>
    <xsl:value-of select="."/>
    </Type>
    <Amount>
    <xsl:value-of select="count(//Nodes/Type[.=$actualType])"/>
    </Amount>
    </xsl:for-each>
    --
    The structure should look like this:
    <Nodes>
    <Type>Boy</Type>
    <Type>Girl</Type>
    <Type>Boy</Type>
    <Type>...</Type>
    </Nodes>


    You should see if preceding is useful for your xsl xsl processor.
    Hope it can help you
    Gonzalo


Sponsored By: