Subject: Re: [xsl] Eliminating Duplicate Elements From: "Vasu Chakkera" <vasucv@xxxxxxxxxxx> Date: Wed, 14 Aug 2002 11:12:35 +0000 |
if you have a structure like the one you have given.. ( i have added <students> as root element..)
<?xml version="1.0"?> <students> <fred> <wilma> <pebbles> one </pebbles> </wilma> </fred>
<fred> <wilma> <pebbles> two </pebbles> </wilma> </fred>
<fred> <wilma> <pebbles> one </pebbles> </wilma> </fred> </students>
and if you want to eliminate the duplicates and print one,two ( the texts in pebbles) instead of one,two, one
then the simplest way of doing this is.. <xsl:template match="/"> <xsl:for-each select="//pebbles[not(. = preceding::pebbles/text())]"> <xsl:value-of select="."/> <xsl:if test="not(position()=last())"> <xsl:text>,</xsl:text> </xsl:if> </xsl:for-each> this would give one , two
From: Antony.Tomasovic@xxxxxxxx Reply-To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx To: XSL-List@xxxxxxxxxxxxxxxxxxxxxx Subject: [xsl] Eliminating Duplicate Elements Date: Wed, 14 Aug 2002 14:33:13 +1000
Hi,
I've read the archives about elimating duplicate elements but still can't seem to get my head around the concept.
Can anyone, in as simple terms as possible, explain how I can use XSL to turn the following XML:
<fred> <wilma> <pebbles> one </pebbles> </wilma> </fred>
<fred> <wilma> <pebbles> two </pebbles> </wilma> </fred>
<fred> <wilma> <pebbles> one </pebbles> </wilma> </fred>
to output as:
<fred> <wilma> <pebbles> one </pebbles> </wilma> </fred>
<fred> <wilma> <pebbles> two </pebbles> </wilma> </fred>
using <xsl:for-each> loops.
Thanks, Antony
Antony Tomasovic
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] Eliminating Duplicate Element, Antony . Tomasovic | Thread | [xsl] xsl-call template problem, Christer Nordvik |
[xsl] Global Variable, aruniima . chakrabar | Date | RE: [xsl] selecting a parameter usi, TSchutzerWeissmann |
Month |