[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

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


Subject: Re: [xsl] Remove duplicates using preceding- or following-siblings
From: David Carlisle <davidc@xxxxxxxxx>
Date: Mon, 02 Apr 2012 15:32:28 +0100

On 02/04/2012 13:20, Satish wrote:
    <xsl:if test="count(preceding-sibling::LibraryBook[@authId =
$authId])">

It would have been easier to answer if you had supplied a full (but small) stylesheet and source rather than snippets that can not be run.


Any kind of grouping is easier in xslt 2 than xslt 1 but you didn't say which you are using. In xslt 1 using a key ("muenchian grouping" is usually more efficient than checking sibling axis but you can optimise that later once it is working)

  <xsl:if test="count(preceding-sibling::LibraryBook[@authId =
$authId])">

That test has to look at the node that is being processed, not teh node being generated. You are processing book nodes at that point so it woul dneed to be


<xsl:if test="count(preceding-sibling::book[@authId = $authId])"

however if you changed your for-each to say
<xsl:for-each select="book[@authorId = $authId][1]">
then you would just pick up the first such node, so would not get duplicates.


David


-- google plus: https:/profiles.google.com/d.p.carlisle

________________________________________________________________________
The Numerical Algorithms Group Ltd is a company registered in England
and Wales with company number 1249803. The registered office is:
Wilkinson House, Jordan Hill Road, Oxford OX2 8DR, United Kingdom.

This e-mail has been scanned for all viruses by Star. The service is
powered by MessageLabs. ________________________________________________________________________



Current Thread
Keywords