Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > XML > XSLT 1.0: Selecint unique nodes only

Thread Tools

XSLT 1.0: Selecint unique nodes only

Zachary Turner
Posts: n/a
I have a bunch of nodes like this:



I perform a select query similar to "a/*" (actually much more
complicated, but the idea is the same), and set the result equal to a

<xsl:variable name="nodeSet" select="a/*"/>

I now want a new variable like this:

<xsl:variable name="uniqueNodeSet" select=""/>

That only returns nodes in the set that do not have the same local-
name() as any other element in the set. So basically just trim out
elements with dupliacte local-names. I know this has come up before,
I did search the usenet archives and there were many posts asking
similar questions, but I was not able to massage the solutions into
one that worked for my case. The best I could do was


but for some reason that doesn't seem to get rid of the duplicates.
I could probably do this using a long drawn out recursive template,
but I'm sure there's an easier way.

Any help greatly appreciated.


Reply With Quote
Joe Kesselman
Posts: n/a
XSLT FAQ entries related to reducing a set to its unique members. Many
of these approaches are related to sorting, but I think some of them are
usable even if you don't sort.

The Muenchian Method really is a nice little hack.

() ASCII Ribbon Campaign | Joe Kesselman
/\ Stamp out HTML e-mail! | System architexture and kinetic poetry
Reply With Quote

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Text nodes and element nodes query asd Java 3 05-23-2005 10:01 AM
finding nodes that don't match other nodes XML 2 01-27-2005 07:26 PM
Looking A Nodes From Within Nodes Johnny Ooi XML 10 11-14-2004 06:55 PM
selecting nodes between other nodes Timo Nentwig XML 1 06-17-2004 04:54 AM
Reality check: Is it sensible to link XML nodes to other XML nodes in the same file? gavnosis XML 0 08-02-2003 08:22 AM