[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Removing duplicates

Subject: Removing duplicates
From: Clay Leeds <cleeds@xxxxxxxxxx>
Date: Tue, 22 Oct 2002 09:18:59 -0700
algorithm removing duplicates
Howdy,

I need to make certain that I don't print the same value twice on a detail line. I have up to 6 values, and I've been trying to brute force it, by making certain it's not equal to a previous item (see below). I display the RC, unless a corresponding TRC exists. BTW, the code below doesn't work (still trying to iron out the kinks). Is there a shorter way to do this? (i.e., one that actually uses XPath :-)

XML INPUT:
<RCDATA>
  <RCDATALINE>
    <RC>66</RC>
    <TRC>02</TRC>
  </RCDATALINE>
  <RCDATALINE>
    <RC>01</RC>
    <TRC>02</TRC>
  </RCDATALINE>
  <RCDATALINE>
    <RC></RC>
    <TRC></TRC>
  </RCDATALINE>
  <RCDATALINE>
    <RC></RC>
    <TRC></TRC>
  </RCDATALINE>
  <RCDATALINE>
    <RC></RC>
    <TRC></TRC>
  </RCDATALINE>
  <RCDATALINE>
    <RC></RC>
    <TRC></TRC>
  </RCDATALINE>
</RCDATA>


XSL INPUT: (BTW, I have a similar/identical template for TRC)

<xsl:for-each select="RCDATALINE">
<xsl:choose>
<xsl:when test="RCDATALINE[1]">
<xsl:apply-templates select="RC"/>
</xsl:when>
<xsl:when test="RCDATALINE[2] and RC[.!=RC[1]]">
<xsl:apply-templates select="RC"/>
</xsl:when>
<xsl:when test="RCDATALINE[3] and RC[.!=RC[1]] and RC[.!=RC[2]]">
<xsl:apply-templates select="RC"/>
</xsl:when>
<xsl:when test="RCDATALINE[4] and RC[.!=RC[1]] and RC[.!=RC[2]] and RC[.!=RC[3]]">
<xsl:apply-templates select="RC"/>
</xsl:when>
<xsl:when test="RCDATALINE[5] and RC[.!=RC[1]] and RC[.!=RC[2]] and RC[.!=RC[3]] and RC[.!=RC[4]]">
<xsl:apply-templates select="RC"/>
</xsl:when>
<xsl:when test="RCDATALINE[6] and RC[.!=RC[1]] and RC[.!=RC[2]] and RC[.!=RC[3]] and RC[.!=RC[4]] and RC[.!=RC[5]]">
<xsl:apply-templates select="RC"/>
</xsl:when>
</xsl:choose>
</xsl:for-each>



- Clay Leeds - Web Developer/Programmer - cleeds@xxxxxxxxxx


XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list



Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.