This week's book giveaway is in the Design forum.
We're giving away four copies of Design for the Mind and have Victor S. Yocco on-line!
See this thread for details.
Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

removing duplicate elements

 
Vijay Chouhan
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Ranchers,

I have some XML data of the following structure.

Now I need to process this data using XSL and ensure that the duplicate elements are output only once. Also the order of the elements should not be changed. The output for the above should look like.

Try as I hard I can, I am not able to make any headway. Will really appreciate any leads.

TIA
 
Radha Voodi
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Try this:

<xsl:template match="@*|node()">
<xsl:if test="not(node()) or not(preceding-sibling::node()[.=string(current()) and name()=name(current()])">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:if>
</xsl:template>

Thanks,
Radha
 
Vijay Chouhan
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey thanks a ton Radha.. You've solved my problem.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic