This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
RE: Correct syntax for removing duplicates from sorted list
- From: "Chris Bayes" <chris at bayes dot co dot uk>
- To: <xsl-list at lists dot mulberrytech dot com>
- Date: Mon, 17 Dec 2001 14:25:57 -0000
- Subject: RE: [xsl] Correct syntax for removing duplicates from sorted list
- Reply-to: xsl-list at lists dot mulberrytech dot com
> <xsl:if test=not".=last">
What is this gobbledygook??????
What processor are you using that you can get ANY result????
Why not just do
<xsl:template match ="/">
<html>
<body>
<xsl:for-each select="LOG/DIRECT/TARGET_CHARACTER_ID[. !=
preceding::TARGET_CHARACTER_ID]">
<xsl:sort select="." data-type="number"
order="ascending" />
<xsl:value-of select="position()" />. <xsl:value-of
select="." />
</xsl:for-each>
</body>
</html>
</xsl:template>
Ciao Chris
XML/XSL Portal
http://www.bayes.co.uk/xml
> -----Original Message-----
> From: owner-xsl-list@lists.mulberrytech.com
> [mailto:owner-xsl-list@lists.mulberrytech.com] On Behalf Of
> Ahmad J Reeves
> Sent: 17 December 2001 13:00
> To: xsl-list@lists.mulberrytech.com
> Subject: [xsl] Correct syntax for removing duplicates from sorted list
>
>
> Hi,
>
> I am trying to remove duplicate copies of context nodes from
> a sorted list. My xml doc looks like this:-
>
> <LOG>
> <DIRECT>
> <COMMUNICATION_TYPE> PAGETELL </COMMUNICATION_TYPE>
> <Invoc_serial> 27 </Invoc_serial>
> <Serial> 3087908 </Serial>
> <USAGE> TELL </USAGE>
> <MESSAGE_TYPE> EMOTE </MESSAGE_TYPE>
> <CHARACTER_ID> 44639 </CHARACTER_ID>
> <CHARACTER_STATUS> 3 </CHARACTER_STATUS>
> <LOCATION_ID> 45040 </LOCATION_ID>
> <TARGET_CHARACTER_ID> 2346456 </TARGET_CHARACTER_ID>
> <TARGET_CHARACTER_STATUS> 6 </TARGET_CHARACTER_STATUS>
> <TARGET_CHARACTER_LOCATION_ID> 23222
> </TARGET_CHARACTER_LOCATION_ID>
> <MESSAGE>hello</MESSAGE>
> <TIME> 'Mon, 26 Nov 2001 15:40:29 +0000' </TIME>
> </DIRECT>
>
> *then a few hundred more like that*
>
> </LOG>
>
> My xml stylesheet as is looks like this:-
>
>
> <xsl:stylesheet
> xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
> version="1.0">
> <xsl:output method="html"/>
>
> <xsl:variable name="last">
> </xsl:variable>
>
> <xsl:template match ="/">
> <xsl:for-each select="LOG/DIRECT/TARGET_CHARACTER_ID">
> <xsl:variable name="last" select="LOG/DIRECT/TARGET_CHARACTER_ID"/>
> <xsl:sort select="." data-type="number"/>
> <xsl:value-of select="position()"/>
> <xsl:text>. </xsl:text>
>
> <html>
> <body>
> <xsl:if test=not".=last">
> <xsl:value-of select="."/><br></br>
> </xsl:if>
> </body>
> </html>
> </xsl:for-each>
> </xsl:template>
> </xsl:stylesheet>
>
> And my sorted but duplicated output is something like this:-
>
> 1. 23220
> 2. 23470
> 3. 23470
> 4. 23470
> 5. 23470
> 6. 23470
> 7. 23470
> 8. 83470
> 9. 212120
> 10. 223232
> 11. 231212
> 12. 2346456
> 13. 27675340
>
> So every time I get to the context node(in this case
> "TARGET_CHARACTER_ID") I need to check if it matches the
> previous one and if so NOT to output it. This should give me
> a unique list rather than a total occurences count. The code
> as is (oops!) just tests to see if it equals itself I think!
> and I've been looking at axis but as I am comparing .=. then
> I'm not sure the best way to proceed, as I need to test with
> the previous 'iteration' as it were.
>
> Any help gratefully received!
>
> Cheers
>
> Ahmad (p.s cheers Jen and Chris for your previous help)
>
>
> XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
>
>
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list