Subject: Re: removing duplicates problem (solved) From: Jeremy Quinn <jeremy@xxxxxxxxxxxxxxxxx> Date: Wed, 29 Dec 1999 13:59:42 +0000 |
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 |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: less than / greater than in coc, Stefano Mazzocchi | Thread | [no subject], David J. Kim |
less than / greater than in cocoon, Tony Fabian | Date | Re: Convert newlines to <BR/>, Jon Smirl |
Month |