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

RE: Duplicate elements. HELP!

Subject: RE: Duplicate elements. HELP!
From: "Stoaks, Max" <Stoaks_Max@xxxxxxxxxxxxxxxx>
Date: Sun, 6 Jun 2004 14:24:50 -0700
companyresults
Thanks Michael,

It works perfectly.

I had also gotten around to:
	<xsl:for-each select="CompanyResults/CompanyResult[not
           (CompanyTitle=preceding::CompanyTitle)]">

Which seems to work as well. But your solution is more succint since I am interested in siblings (same level) only and not ancestors, for example.

Thanx again!
Max

-----Original Message-----
From: Michael Kay [mailto:mhk@xxxxxxxxx]
Sent: Sunday, June 06, 2004 1:39 PM
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject: RE:  Duplicate elements. HELP!


Your wrote

	<xsl:for-each select="CompanyResults/CompanyResult[not
 
(./CompanyTitle=preceding::CompanyResults/CompanyResult/CompanyTitle)]">


No CompanyResult has a preceding CompanyResults, because ancestors of an
element are not included on the preceding axis. Even if they were, this
condition wouldn't work because the CompanyResult children of the
CompanyResults include the element you started from, which is always equal
to itself. 

You want
 
	<xsl:for-each select="CompanyResults/CompanyResult[not
           (CompanyTitle=preceding-sibling::CompanyResult/CompanyTitle)]">

Michael Kay	
 

> -----Original Message-----
> From: Stoaks, Max [mailto:Stoaks_Max@xxxxxxxxxxxxxxxx] 
> Sent: 06 June 2004 18:19
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Cc: Stoaks, Max
> Subject:  Duplicate elements. HELP!
> 
> Hi,
> 
> I'm trying to ignore duplicate elements and having trouble 
> with the XPath syntax. I'm hoping some kind soul can help...
> 
> 
> Here's my xml:
> <CompanyResults>
> 	<CompanyResult>
> 		<CompanyTitle>IBM</CompanyTitle>
> 		<CompanyContact>Joe</CompanyContact>
> 	</CompanyResult>
> 	<CompanyResult>
> 		<CompanyTitle>IBM</CompanyTitle>
> 		<CompanyContact>Joe</CompanyContact>
> 	</CompanyResult>
> 	<CompanyResult>
> 		<CompanyTitle>Intuit</CompanyTitle>
> 		<CompanyContact>Claudia</CompanyContact>
> 	</CompanyResult>
> 	<CompanyResult>
> 		<CompanyTitle>IBM</CompanyTitle>
> 		<CompanyContact>Joe</CompanyContact>
> 	</CompanyResult>
> </CompanyResults>
> 
> I want to ignore any CompanyResult that has a CompanyTitle 
> that has already occured.
> 
> <xsl:template match="/">
> 	<xsl:for-each select="CompanyResults/CompanyResult[not
>            
> (./CompanyTitle=preceding::CompanyResults/CompanyResult/Compan
> yTitle)]">	
> 			<xsl:value-of select="CompanyTitle"/>	
> 	</xsl:for-each>	
> 
> Any help would be greatly appreciated as I've been pulling my 
> hair out about this...
> 
> I'm using XalanJ 2.6.
> 
> Thanks!
> Max
> 
> 
> --+------------------------------------------------------------------
> XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
> To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
> or e-mail: <mailto:xsl-list-unsubscribe@xxxxxxxxxxxxxxxxxxxxxx>
> --+--
> 
> 



--+------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe@xxxxxxxxxxxxxxxxxxxxxx>
--+--


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.