Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
|
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old August 9th, 2004, 04:59 PM
Authorized User
 
Join Date: Jul 2003
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
Default Element value to be shown only once...HOW?

Hi all,

Below is the XML I have,

<root>
      <CREDITCOMMENT>
          <Comment>BIG LINE 1</Comment>
      </CREDITCOMMENT>
      <CREDITCOMMENT>
          <Comment>Active Duty</Comment>
      </CREDITCOMMENT>
      <CREDITCOMMENT>
          <Comment>BIGPERSON BILL</Comment>
      </CREDITCOMMENT>
      <CREDITCOMMENT>
          <Comment>BIGPERSON BILL</Comment>
      </CREDITCOMMENT>
      <CREDITCOMMENT>
          <Comment>BIGPERSON BILL</Comment>
      </CREDITCOMMENT>
      <CREDITCOMMENT>
          <Comment>BIGPERSON BILL</Comment>
      </CREDITCOMMENT>
      <CREDITCOMMENT>
          <Comment>Active Duty</Comment>
      </CREDITCOMMENT>
      <CREDITCOMMENT>
          <Comment>BIG LINE 1</Comment>
    </CREDITCOMMENT>
</root>

Can someone help me in writting the xsl so that the html will display the Comment only once, Like, below????

========================
BIG LINE 1
Active Duty
BIGPERSON BILL
========================

Thanks in-advance
Suri

 
Old August 10th, 2004, 07:38 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,212
Thanks: 0
Thanked 1 Time in 1 Post
Default

eliminate the duplicates with a selection like this:
Code:
<xsl:apply-templates select="root/CREDITCOMMENT[not(Comment=preceding-sibling::CREDITCOMMENT/Comment)]"/>
output the comment with a template like this:
Code:
<xsl:template match="CREDITCOMMENT">
    <xsl:value-of select="Comment"/><br/>
</xsl:template>
 
Old August 10th, 2004, 10:51 AM
Authorized User
 
Join Date: Jul 2003
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks alot..!

It works.

regards
suri






Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem adding element to the previous element dani1 XSLT 5 September 10th, 2008 01:38 AM
results shown by query Vince_421 Access 1 February 4th, 2007 12:45 PM
SetDataSource is ignored, the whole table is shown anjulis Crystal Reports 0 October 20th, 2006 12:26 PM
adding of element and assigning to one element sushovandatta XSLT 2 November 16th, 2004 07:04 PM
How to verify if form is shown pavel VB How-To 3 October 1st, 2004 01:10 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.