[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Lookup, eliminating duplicates and sorting

Subject: Re: Lookup, eliminating duplicates and sorting
From: "Manfred Staudinger" <manfred.staudinger@xxxxxxxxx>
Date: Wed, 19 Jul 2006 15:45:02 -0700
Re:  Lookup
Most elegant, thanks! I'm sure I can learn a lot
from this ...

On 19/07/06, Dimitre Novatchev <dnovatchev@xxxxxxxxx> wrote:
> xslt 1.0 - I've a set of nodes, for which I want
> a. to replace some values (most will not change), then
> b. eliminate the duplicates and sort them.
> The text nodes represent URI's and are then used to
> create html links. So far I was only able to write in
> 2 different task what should be done in one:

One simple way to do this:

The following transformation:

<xsl:stylesheet version="1.0"

<xsl:output omit-xml-declaration="yes" indent="yes"/>

 <xsl:key name="kb" match="b[not(. = ../../e2/f/@c)]"

 <xsl:key name="kb" match="@b1"
  use="../../../e1/b[. = current()/../@c]"/>

  <xsl:key name="kDist" match="b | @b1"

        <xsl:template match="/">
            <xsl:for-each select=
             "key('kb', */e1/b)[generate-id()
                                generate-id(key('kDist', .)[1])

        <b2><xsl:value-of select="."/></b2>

when applied on the provided source xml document:

                <f c="abe" b1="abc"/>
                <f c="abf" b1="abj"/>
                <f c="abg" b1="abi"/>
                <f c="abh" b1="abi"/>

produces the wanted result:


Hope this helped.

Dimitre Novatchev
Truly great madness cannot be achieved without significant intelligence.

Current Thread


Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
First Name
Last Name
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.