Subject: Re: [xsl] duplicate test From: Jeni Tennison <jeni@xxxxxxxxxxxxxxxx> Date: Tue, 9 Apr 2002 14:46:36 +0100 |
Hi Ahmad, > I'm trying to remove duplicates from a list of characters when they > are sending multiple messages in a room until they leave and come > back in. My stylesheet is as follows: - [snip] > <xsl:template match="/"> > <xsl:for-each select="$vLocations"> > <xsl:value-of select="concat('Location: ', LOCATION_ID, ':', $NL )" /> > <xsl:for-each select="/LOG/*/LOCATION_ID [. = current()/LOCATION_ID]"> Why not use the key again here? It will be a lot quicker: <xsl:for-each select="key('kByID', LOCATION_ID)"> ... </xsl:for-each> > <xsl:if test="not(../CHARACTER_ID = > ../preceding-sibling::DIRECT > [CHARACTER_ID = current()[1]/CHARACTER_ID)"> Something's gone wrong here. That isn't a valid XPath expression (there's no closing ] character for the predicate), and I don't think that it would do what you want even if it was. I think that what you're trying to do here is see if the last DIRECT element that involved the character that's involved in this DIRECT, LOCAL, GLOBAL or ADMIN element involved the same location. Is that correct? If so, you need (assuming that you use the modified xsl:for-each above): <xsl:if test="not(preceding-sibling::DIRECT [CHARACTER_ID = current()/CHARACTER_ID][1] /LOCATION_ID = LOCATION_ID)"> ... </xsl:if> > <xsl:value-of select="concat(' ', ../CHARACTER_ID, $NL)" /> If you make the change to the xsl:for-each, you'll have to amend this to: <xsl:value-of select="concat(' ', CHARACTER_ID, $NL)" /> When I test these changes with the sample data you sent, I get: Location: 24488 : 10010 10010 Location: 34567 : 10010 Location: 31132 : 20241 Which is what you wanted. Cheers, Jeni --- Jeni Tennison http://www.jenitennison.com/ XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] duplicate test, Ahmad J Reeves | Thread | [xsl] Call Java Objects, Laura Jenkins |
RE: [xsl] Call Java Objects, Venkateshwar Bommine | Date | RE: [xsl] problem converting date f, Serrell, Rachael |
Month |