Re: [xsl] Remove duplicates using preceding- or following-siblings

Subject: Re: [xsl] Remove duplicates using preceding- or following-siblings
From: Satish <p.satishchandra@xxxxxxxxx>
Date: Mon, 2 Apr 2012 23:28:25 +0530
Thanks a lot everyone. I apologize for the sample - the actual data I
have is quite complex and proprietary; I was denied permission to
share it in public domain. Hence the not-so-good sample.

We are on XSLT 1.0, running Apache's XalanJ 2.7.

I was able to remove the duplicates later on using my xsl variable
($authorList in the sample) in the following way

<xsl:for-each select="$authorList/LibraryBook[not(@authId =
preceding-sibling::LibraryBook/@authId)]">
    <!-- unique books only -->
</xsl:for-each>

But now I found that there was a costly operation (not in sample) on
each of the <LibraryBook> node written to my xsl variable; so was
trying to avoid writing multiple <LibraryBook> nodes, do the costly
operation and then later on remove duplicates. I wondered if there was
somehow a way to access the nodes already written/generated so that I
could write just the ones that are unique.

The reason I said that I could not remove duplicates by checking for
the 'book' nodes is because we use an extension (Java obviously) that
returns the 'book' node. Although it is from the same XML, we get it
via an extension after some geometry related processing.

I apologize again - all this doesn't help without a working sample.
I'll try to get a sample working.

I honestly thank everyone for their helpful answers. I can't appreciate more.

Thanks
Satish

Current Thread