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

How to remove double elements?????

Subject: How to remove double elements?????
From: ChivaBaba@xxxxxxx
Date: Thu, 16 May 2002 12:16:02 EDT
xsl remove double element
Hi,

I have some pretty fussy code to copy some elements from an xml-file, sort them amd eliminate double elements:

++++++++++++++++++++++++++++++++++++++++++++++++++++++++

<!-- get for each computer in sw-file the corresponding computer in hw-file-->   
 
 <xsl:variable name="computer">
  <xsl:for-each select="tool">
      
<!--.... build the key of the current tool .........-->

   <xsl:variable name="key" select="concat(@name,'#',@version)"/>

<!-........ change context for key lookup ..........-->
      
   <xsl:for-each select="$sw-file">  
    <xsl:variable name="release" select="key('releasekey',$key)"/>     
    <xsl:for-each select="$release/computer">
     <xsl:variable name="name_key" select="@name"/>

<!--.......... change context for key lookup .......-->
      
     <xsl:for-each select="$hw-file">
      <xsl:copy-of select="key('hw_key',$name_key)"/>  
     </xsl:for-each>
    </xsl:for-each>
   </xsl:for-each>
  </xsl:for-each>
 </xsl:variable>

<!--.............. get sorted computer-list .......-->
 
 <xsl:variable name="sorted_hw">
  <xsl:for-each select="exsl:node-set($computer)/computer">
   <xsl:sort data-type="text" lang="en" select="@function"/>
   <xsl:sort data-type="text" lang="en" select="@name"/>
   <xsl:copy-of select="."/>
  </xsl:for-each>
 </xsl:variable>

<!--........... remove double elements .............-->

 <xsl:variable name="hw">
  <xsl:for-each select="exsl:node-set($sorted_hw)/computer">
   <xsl:if test="preceding-sibling::computer[1]/@name != @name">
    <xsl:copy-of select="."/>
   </xsl:if>
  </xsl:for-each>
 </xsl:variable>

++++++++++++++++++++++++++++++++++++++++++++++++++++++++

1.)
Is there an elegant possibility to remove double elements??? By using my version the first element gets lost!!

2.) 
Is it possible to get these functionaltities with LESS code (especially with LESS variables)??????

Many thanks in advance!!!

Cheers,

Stefan

 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.