XSLT 1.0: Selecint unique nodes only

Z

Zachary Turner

I have a bunch of nodes like this:

<a>
<b>
<b>
<c>
</a>

<a>
<b>
<c>
<d>
<f>
</a>

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
variable.

<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

select="$nodeSet[not(local-name()=local-name(a/*))]"

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.

Thanks
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,994
Messages
2,570,223
Members
46,813
Latest member
lawrwtwinkle111

Latest Threads

Top