[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: removing duplicates problem (solved)

Subject: Re: removing duplicates problem (solved)
From: Jeremy Quinn <jeremy@xxxxxxxxxxxxxxxxx>
Date: Wed, 29 Dec 1999 13:59:42 +0000
jeremy quinn
On 29/12/99 at 2:30 am, I wrote:

>Date: Tue, 28 Dec 1999 20:29:53 +0000
>From: Jeremy Quinn <jeremy@xxxxxxxxxxxxxxxxx>
>Subject: removing duplicates problem
>
>I am in the situation of wanting to create a node-set of all the 
>    <person idref="Smith"/> and <author idref="Jones"/> tags with unique idref 
>attributes. The tags can be found almost anywhere in the document.

I solved the problem ... and am posting it here in case it helps anyone else ...

First I simplified the problem by converting:

    <author idref="name"/> to
    
    <author><person idref="name"/></author>

to reduce the number of different things I was looking for.


The following XSL now works ....

<xsl:template name="people">
    <xsl:variable 
        name="unique"   
        select="//person[not(./@idref=following::person/@idref)]"
        />
    <xsl:for-each select="$unique">
        <xsl:variable name="pid" select="@idref"/>
        <xsl:for-each select="document('../xml/data/people.xml')">
            <xsl:apply-templates select="id($pid)"/>
        </xsl:for-each>
    </xsl:for-each>
</xsl:template>

It gives me a list of <people> with no duplicates, in document order, then looks them up in the "people.xml" file.

Result!

If anyone has any suggestions about how to optimise this, I'd be glad to hear.
I'm sure there's a way to only call document() once ....

thanks Jeremy

   ___________________________________________________________________

   Jeremy Quinn                                           Karma Divers
                                                       webSpace Design
                                            HyperMedia Research Centre

   <mailto:jeremy@xxxxxxxxxxxxxxxxx>     <http://www.media.demon.co.uk>
    <phone:+44.[0].207.737.6831>        <pager:jermq@xxxxxxxxxxxxxxx>



 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.