xsl-list
[Top] [All Lists]

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

2012-04-02 10:10:48
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. ________________________________________________________________________

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--